Add support for verifying server certs against SPIFFE IDs
This adds support to "certigo connect" to verify that the
server presented a certificate for a specific hostname or
SPIFFE ID. This name can now be unrelated to the hostname
to connect to and the Server Name Indication (SNI) to send
to the server during the TLS handshake.
Prior to this commit, the name expected in the certificate
could only be a hostname, specified either via --name (SNI)
or the hostname to connect to. SPIFFE IDs -- URLs with
"spiffe" as the scheme -- are not useful as hostnames or
SNIs. As a result, this commit adds a new --expected-name
switch to certigo connect. This override provides full
control over what name to expect in the server certificate
presented during the TLS handshake. For example, this name
can now be different from the hostname connected to and the
name specified in Server Name Indication (SNI). Moreover,
if --expected-name is a URL with "spiffe" scheme, it is
only matched against Subject Alternative Names of type URI,
as per the SPIFFE spec.
Error when no valid certs are found when verifying instead of accessing oob.
Warn when CSRs are found instead of silently ignoring them.
Co-authored-by: Mat Byczkowski <mbyczkowski@gmail.com>
This splits the logic into a cli, which handles parsing command line args and
reading files, and a terminal abstraction for handling user input and ouput.
All uses of os.Exit are removed in favor of returning errors.
Overall this enables better testing and reuse of code. Previously we had to
rely on external unit testing for CLI tests, which are harder to write tests.
I found TP-LINK routers submit some kind of logging to
n-devs.tplinkcloud.com:50443 and the CA that signed the certificate
for that domain had DCs in its subject
With this change we now get:
Issuer:
DC=cn, DC=com, DC=tp-link, CN=TP-LINK CA P1
Todo: Right now it doesn't support any truststore password other than changeit.
That's what Java ships. A follow-up commit will add better password handling