32 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 3a0d8c2c97 Support tls.Config in psql fork
This commit modifies the psql fork to accept a `*tls.Config` when
dumping TLS info. This allows us to pass the same broad
cipher suite configuration that we use for other connection types,
which preserves compatibility with older Go defaults. It also has
the side effect of hooking up the client certificate request info
callback, which means that Certigo now reports details about the
expected client certificate for Postgres connections.

In the future, we should eliminate our need for this fork by
switching to the `pgx` package and extracting the certificates via
new hooks in the `*tls.Config` struct, rather than patching this
outdated fork.
2025-07-25 17:24:52 -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 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
guoguangwu 813ad1d5a6 chore: slice replace loop 2023-07-03 16:16:43 +08:00
John Wood 44210f297c Remove ioutil (#289) 2022-08-11 10:59:59 -07:00
Eli Young 908eebe3d9 Avoid nil deref when using Postgres StartTLS
Fixes #234
2021-07-15 13:04:33 -07: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
Matthew McPherrin e336bddafc Add support for proxy authentication
This only supports the simplest case: a username and password in the proxy URL,
and http basic auth.
2020-01-09 22:56:50 -08:00
Cedric Staub 25850151d7 Rename dumpAuthTLSFromXXX methods 2019-05-21 11:20:24 -07:00
Seth Theriault 75258cfd3c Add support for IMAP STARTTLS 2019-05-21 11:57:46 -04:00
CodeLingo Bot f328dcd6cc Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-02-18 11:35:49 +00:00
Cedric Staub 399ed9bc6e Fix SNI handling, set server name for connect 2018-04-03 21:47:37 -07:00
Matthew McPherrin 58f10be303 Add an aliased --starttls. DRY the protocols by putting them in starttls.go
Unfortunately kingpin doesn't support natively support aliased flag names, so
you can supply both --start-tls and --starttls without an error, but that's
just "holding it wrong".
2018-03-14 18:09:03 -07:00
Matthew McPherrin c22acb0991 More robust parsing of FTP protocol
I found some servers don't always return a space after the three-digit code
for example,

certigo connect --start-tls ftp ftp.mirrorservice.org:21
error connecting: FTP server responded with status 220-----------------------------------------------------------------------------
, was expecting 220

Instead, we always take the first three digits and parse them as an integer, rather than
relying on the space.  Makes the code look a little cleaner too, by returning it as an int.
2018-03-14 18:08:41 -07:00
Matthew McPherrin cbdcc47d56 Add protocol-specific default ports
If otherwise unspecified, default to port 443.
If a starttls protocol is given, use a protocol-specific default.

So now "certigo connect squareup.com" works.
2018-03-10 19:38:29 -08:00
Cedric Staub 15a4a957d6 Add HTTP(S) CONNECT proxy support to certigo 2017-10-11 15:53:44 -07:00
Cedric Staub 5a9a11db35 Add support for showing requested client certificate info 2017-04-08 14:55:37 -07:00
Matthew McPherrin b61f9af0af Review feedback: Flag named --identity and a better description
Validate --identity can only be used with --start-tls
2017-03-31 23:57:29 -07:00
Matthew McPherrin 60f1c25a94 Add a --asuser flag which sets DB user & stmp EHLO hostname. 2017-03-31 15:36:38 -07:00
Matthew McPherrin 0232a800cf smtp hello as certigo 2017-03-31 13:51:01 -07:00
Cedric Staub c3b6ec93dc Support connect timeouts 2017-03-09 15:03:56 -08:00
Cedric Staub 2404cbbd3d Implement AUTH TLS for FTP servers 2017-02-24 20:29:43 -08:00
Matthew McPherrin c368df917a Allow SSL 3.0, so we can see old and bad servers. 2017-02-19 14:36:31 -08:00
Matthew McPherrin 5c0832b26f ldap starttls support 2017-02-18 23:45:16 -08:00
Matthew McPherrin 84fb87afa5 Add TLSConnectionState() method to forked ldap package 2017-02-18 23:45:16 -08:00
Matthew McPherrin 65c225f0e3 Vendor starttls for forking 2017-02-18 23:45:16 -08:00
Matthew McPherrin 0e9f91f9cc Change some variable names in the starttls package
They made sense in the certigo main() context, but seem weird here.
2017-02-18 23:28:42 -08:00
Matthew McPherrin 27ac287248 Panic for impossible error 2017-02-17 15:56:19 -08:00
Matthew McPherrin 4cc48a1ee6 Add SMTP support to STARTTLS 2017-02-17 15:49:03 -08:00
Matthew McPherrin 98dbc46373 Remove print and os.Exit from starttls library 2017-02-17 15:34:18 -08:00
Matthew McPherrin 35679297a9 Move StartTLS functionality into a subpackage, enabling use elsewhere
This moves two functions out of main.go.
The only change to the functions was to make them take arguments, instead of using global variables in main.

The mysql and psql imports are moved here too.
2017-02-17 12:39:57 -08:00