71 Commits
Author SHA1 Message Date
Nik Unger 68183f4853 Add and enforce copyright headers via linter
This commit normalizes copyright headers across the codebase.
2025-07-28 13:05:13 -04:00
Nik Unger 7254eb963e Update zlint
This commit updates zlint to the latest version. The new version's
`e_key_usage_and_extended_key_usage_inconsistent` linter contains a
bug, so this commit disables it. The new version also correctly
identifies an error with some of the test certificates, so the
commit adds the error to the expected output (rather than
regenerating the certificates with modern policies).
2025-07-25 17:24:55 -04:00
Nik Unger 89abb046f6 Delete vendored ldap package in favor of upstream
`github.com/go-ldap/ldap/v3` now supports the two features that we
previously added to a local fork: extracting the TLS connection
state, and defining a connection timeout. This commit deletes the
fork and uses the upstream dependency.

This commit also adjusts the `certigo connect` TLS configuration to
support every cipher suite supported by `crypto/tls`, including
insecure ones. This improves the ability to extract certificates
from servers with poor cipher suite support. This limitation was
uncovered while testing LDAP connectivity.
2025-07-25 17:24:49 -04:00
Nik Unger 2083fae45b Perform all trivial dependency updates
This commit updates every dependency that does not break behavior
or conflict with a pseudo-vendored package.
2025-07-25 17:24:46 -04:00
Nik Unger 7534e225a6 Update to Go 1.24, sprig v3
This commit upgrades the language version to Go 1.24.4 and upgrades
the Sprig templating dependency from v2 to v3 in order to resolve
an indirect dependency issue. The major upgrade of Sprig changes
the behavior of some functions, but not in a significant way.

Go 1.23 introduced a change that rejects X.509 certificates with
negative serial numbers, due to Go's focus on the Web PKI
(see golang/go#71606). We continue to support negative serials by
setting a go:debug option for the main certigo binary, but other
users of certigo packages will need to set their own GODEBUG
settings appropriately to support this feature. If Go eventually
drops support, then we will, too.
2025-07-25 17:24:42 -04:00
Nik Unger 10bbc8cdc1 Fix current linter findings
This commit adds an explicit `golangci-lint` configuration that
simply matches the default linters previously in use, and then
fixes all current linter findings.

Aside from tweaking error message strings, this commit introduces
one externally visible behavior change: PEM data generated from
PKCS#12 files now correctly identifies private key blocks as
`RSA PRIVATE KEY` or `EC PRIVATE KEY`, whereas previously it
generated invalid `PRIVATE KEY` blocks with non-PKCS#8 data.

This commit lays the groundwork for more aggressive linting in the
future, and identifies some additional issues via TODOs.
2025-07-24 12:59:48 -04:00
Michael Weissbacher d3cbd15890 CT Log update
go generate ./...
2025-06-23 17:02:16 -04:00
John Wood abfe56fea8 Fetch latest CT log info (#297) 2022-11-17 13:10:15 -08:00
Cedric Staub 75f2ec06b4 Switch to using SSLMate's PKCS#12 library (#293) 2022-09-21 10:36:59 -07:00
John Wood 44210f297c Remove ioutil (#289) 2022-08-11 10:59:59 -07:00
eea7ad61c3 Add zlint support (#286)
Co-authored-by: John Wood <jwood@squareup.com>
Co-authored-by: Sven Wick <sven.wick@gmx.de>
2022-08-01 12:01:38 -06:00
John Wood 79f1ecf29f Unconditionally add forward slash in OCSP GET requests (#282) 2022-07-01 13:41:01 -07:00
John Wood 0a56dcc30e Use Go generate instead of a makefile (#279)
* Use Go generate instead of a makefile

* Meet the go generate specifications
2022-06-30 11:09:52 -07:00
John Wood 37a41318ba Add support for printing SCTs (#277)
* Address PR comments
2022-06-29 17:35:59 -07:00
John Wood 4c8f1c5862 Fix OCSP checking (#274)
Fixes #272. The root of the problem is that we're asking the wrong OCSP servers. The current code does something like:

leaf, issuers := chain[0], chain[1:]
for _, issuer := range issuers {
  // check for revocation of leaf via issuer.OCSPServer
}

The main problem is that OCSPServer is the URI of the OCSP server for that certificate, and by asking issuer.OCSPServer about leaf, we're requesting OCSP responses from the wrong server. We should be checking leaf.OCSPServer in this example instead of issuer.OCSPServer.

The second problem is that the loop makes no sense. One would not expect any OCSP server in a given chain to be authoritative for a given leaf.

If you do certigo connect google.com, you'll see

Certificate has OCSP extension, but was unable to check status:
	ocsp: error from server: unauthorized

The "unauthorized" means the OCSP server we asked doesn't know anything about the cert we asked about.
2022-06-28 14:51:03 -07:00
John Wood 8f0d49f5b3 Don't check OCSP if there are no OCSP servers in the chain (#255) 2022-02-09 10:07:55 -08:00
klyubin ba10cd1db7 Add support for verifying server certs against SPIFFE IDs (#252)
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.
2022-01-10 15:57:47 -08:00
John Wood 4032ab142c Add the Ed25519 algo to the list of known algo names (#250) 2021-11-30 15:19:09 -08:00
Jason Riddle 5cba65cd46 Add additional TLS 1.3 cipher suites (#208)
The new TLS 1.3 cipher suites do not specify the key exchange algorithm
and as a result "_WITH_" is no longer present.
2020-02-26 10:29:40 -08:00
Roy Xu f81df5c5a3 print input format guessed by certigo (#210) 2020-02-25 11:17:01 -08:00
Roy XuandMat Byczkowski 23ed60d1d5 better error handling for csrs (#211)
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>
2020-02-25 10:58:06 -08:00
Matthew McPherrin 26cd65d9bd refactor certigo package main
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.
2020-01-13 15:58:53 -08:00
Cedric Staub 79de7d2a35 Fix panic in explainCipher for TLS 1.3 ciphers 2019-06-07 12:47:52 -07:00
Matthew McPherrin b6e169d63a Add DomainComponent from RFC 2247
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
2019-03-27 22:51:22 -07:00
Cedric Staub d9c0b44abc Use Go 1.11, use built-in functions for URI names 2018-10-23 14:36:44 -07:00
Cedric Staub 4dba9b2f4e Improve reliability of OCSP checks 2018-04-06 13:06:05 -07:00
Cedric Staub 594b04e874 Print revocation reason & staple status 2018-04-05 16:01:17 -07:00
Matthew McPherrin f07f7d351c Support any format certigo does for CAs.
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
2018-04-04 21:21:46 -07:00
Matthew McPherrin c58011aee0 Move ocsp.go and verify.go into lib
This reduces a bunch of copy-paste code.
2018-04-04 21:21:46 -07:00
Cedric Staub 57f83216c3 Update vendored dependencies 2018-04-03 22:21:23 -07:00
Cedric Staub 796d17c565 Better error message for library users 2018-03-22 13:30:07 -07:00
Cedric Staub d920cab6f0 Print only CN for verify results 2018-02-27 17:24:48 -08:00
Cedric Staub 63a3260918 Better short names for printing 2018-02-27 17:09:50 -08:00
Cedric Staub 7c6b521735 Support new name constraint fields in crypto/x509 2018-02-27 16:50:42 -08:00
Cedric Staub 6a549158f0 Better language for outdated signature algorithm warning 2017-11-08 11:20:57 -08:00
Cedric Staub b0d0880545 Fix template bug from moving name constraints 2017-11-08 11:20:42 -08:00
Cedric Staub 1929b65f41 Show OCSP servers and issuing certificate URL info in verbose mode 2017-09-22 12:56:36 -07:00
Cedric Staub 2f2e914e35 Fix DNS name constraints handling 2017-08-18 12:52:26 -07:00
Cedric Staub 772a9edd2b Display SPIFFE URI names if present in certificate 2017-08-07 16:43:48 -07:00
Cedric Staub 55f84d5812 Display SPIFFE URI names if present in certificate 2017-08-07 15:59:33 -07:00
Cedric Staub 1ba652071c Add GOST algorithms in signature scheme map 2017-06-16 17:31:41 -07:00
Cedric Staub 83191051cb Better strings for TLS signature schemes 2017-06-16 17:17:07 -07:00
Cedric Staub 897051b6a5 Add warning for certs w/o subject alt names 2017-06-01 17:36:59 -07:00
Cedric Staub 589481e437 Add user id OID in lib/oids 2017-05-11 10:24:35 -07:00
Cedric Staub fe74b984aa Better error handling in certigo dump command 2017-05-09 14:41:34 -07:00
Cedric Staub 5a9a11db35 Add support for showing requested client certificate info 2017-04-08 14:55:37 -07:00
Cedric Staub 5a26bbac2a Compress output of alternative names and emails 2017-03-10 17:00:01 -08:00
Cedric Staub 9d4a46981e Only print Common Name in non-verbose output 2017-03-10 16:34:28 -08:00
Matthew McPherrin 2b1e3d0dfd Remove whitespace before colon 2017-02-26 20:29:39 -08:00
Matthew McPherrin d1f35820e3 Use one-line dates in --verbose too 2017-02-26 18:17:09 -08:00