Giter VIP home page Giter VIP logo

certigo's Introduction

certigo

license release build report

Certigo is a utility to examine and validate certificates to help with debugging SSL/TLS issues.

Features

Supports all common file formats: Certigo can read and dump certificates in various formats. It can automatically detect and read from X.509 (DER/PEM), JCEKS, PKCS7 and PKCS12 files. Certificates can be dumped to a human-readable format, a set of PEM blocks, or a JSON object for use in scripting.

Validation and linting: Not sure if your generated certificate is valid? Certigo can connect to remote servers to display and validate their certificate chains. It can also point out common errors on certificates, such as using an older X.509 format, signatures with outdated hashes, or keys that are too small.

Supports STARTTLS Protocols: Trying to debug SSL/TLS connections on a database or mail server? Certigo supports establishing connections via StartTLS protocols for MySQL, PostgreSQL, SMTP, LDAP, IMAP, and FTP, making it possible to debug connection issues or scan for expired certificates more easily.

Scripting support: All commands in certigo have support for optional JSON output, which can be used in shell scripts to analyze or filter output. Combine certigo with jq to find all certificates in a bundle that are signed with SHA1-RSA, or filter for CA certificates, or whatever you need!

Install

To install certigo, simply use:

go install github.com/square/certigo@latest

On macOS you can also use homebrew to install:

brew install certigo

Note that certigo requires Go 1.12 or later to build.

Develop

We use Go modules for managing vendored dependencies. If you would like to contribute, see the CONTRIBUTING.md file for extra information.

Usage

Certigo has commands to dump certificates and keystores from a file, to connect and fetch certificates from a remote server, and to verify the validity of certificates in a file. All commands can produce JSON output with the --json flag which can be used for scripting. See below for a full list of options.

usage: certigo [<flags>] <command> [<args> ...]

A command line certificate examination utility.

Flags:
      --help     Show context-sensitive help (also try --help-long and --help-man).
  -v, --verbose  Print verbose
      --version  Show application version.

Commands:
  help [<command>...]
    Show help.


  dump [<flags>] [<file>...]
    Display information about a certificate from a file/stdin.

    -f, --format=FORMAT      Format of given input (PEM, DER, JCEKS, PKCS12; heuristic if missing).
    -p, --password=PASSWORD  Password for PKCS12/JCEKS key stores (reads from TTY if missing).
    -m, --pem                Write output as PEM blocks instead of human-readable format.
    -j, --json               Write output as machine-readable JSON format.
    -l, --first              Only display the first certificate. This flag can be paired with --json or --pem.

  connect [<flags>] [<server:port>]
    Connect to a server and print its certificate(s).

    -n, --name=NAME           Override the server name used for Server Name Indication (SNI).
        --ca=CA               Path to CA bundle (system default if unspecified).
        --cert=CERT           Client certificate chain for connecting to server (PEM).
        --key=KEY             Private key for client certificate, if not in same file (PEM).
    -t, --start-tls=PROTOCOL  Enable StartTLS protocol ('ldap', 'mysql', 'postgres', 'smtp' or 'ftp').
        --identity=certigo    With --start-tls, sets the DB user or SMTP EHLO name.
        --proxy               Optional URI for HTTP(s) CONNECT proxy to dial connections with.
        --timeout=5s          Timeout for connecting to remote server (can be '5m', '1s', etc).
    -m, --pem                 Write output as PEM blocks instead of human-readable format.
    -j, --json                Write output as machine-readable JSON format.
    -l, --first               Only display the first certificate. This flag can be paired with --json or --pem.
        --verify              Verify certificate chain.
        --expected-name       Name expected in the server TLS certificate. Defaults to name from SNI or, if SNI not overridden, the hostname to connect to.

  verify --name=NAME [<flags>] [<file>]
    Verify a certificate chain from file/stdin against a name.

    -f, --format=FORMAT      Format of given input (PEM, DER, JCEKS, PKCS12; heuristic if missing).
    -p, --password=PASSWORD  Password for PKCS12/JCEKS key stores (reads from TTY if missing).
    -n, --name=NAME          Server name to verify certificate against.
        --ca=CA              Path to CA bundle (system default if unspecified).
    -j, --json               Write output as machine-readable JSON format.

Examples

Display information about a certificate (also supports --pem and --json output):

$ certigo dump --verbose squareup-2016.crt
** CERTIFICATE 1 **
Serial: 260680855742043049380997676879525498489
Valid: 2016-07-15 20:15 UTC to 2017-07-31 20:45 UTC
Signature: SHA256-RSA
Subject Info:
	Country: US
	Province: California
	Locality: San Francisco
	EV Incorporation Country: US
	EV Incorporation Province: Delaware
	Organization: Square, Inc.
	Business Category: Private Organization
	EV Incorporation Registration Number: 4699855
	CommonName: www.squareup.com
Issuer Info:
	Country: US
	Organization: Entrust, Inc.
	Organizational Unit: See www.entrust.net/legal-terms
	Organizational Unit: (c) 2014 Entrust, Inc. - for authorized use only
	CommonName: Entrust Certification Authority - L1M
Subject Key ID: D4:17:14:6F:0B:C5:20:A1:D6:FE:21:7E:DC:9E:F8:57:9C:ED:AE:6A
Authority Key ID: C3:F7:D0:B5:2A:30:AD:AF:0D:91:21:70:39:54:DD:BC:89:70:C7:3A
Basic Constraints: CA:false
Key Usage:
	Digital Signature
	Key Encipherment
Extended Key Usage:
	Server Auth
	Client Auth
Alternate DNS Names:
	www.squareup.com, squareup.com, account.squareup.com, mkt.com,
	www.mkt.com, market.squareup.com, gosq.com, www.gosq.com, gosq.co,
	www.gosq.co

Display & validate certificates from a remote server (also supports --start-tls):

$ certigo connect --verbose squareup.com:443
** TLS Connection **
Version: TLS 1.2
Cipher Suite: ECDHE_RSA key exchange, AES_128_GCM_SHA256 cipher

** CERTIFICATE 1 **
Serial: 260680855742043049380997676879525498489
Valid: 2016-07-15 20:15 UTC to 2017-07-31 20:45 UTC
Signature: SHA256-RSA
Subject Info:
	Country: US
	Province: California
	Locality: San Francisco
	EV Incorporation Country: US
	EV Incorporation Province: Delaware
	Organization: Square, Inc.
	Business Category: Private Organization
	EV Incorporation Registration Number: 4699855
	CommonName: www.squareup.com
Issuer Info:
	Country: US
	Organization: Entrust, Inc.
	Organizational Unit: See www.entrust.net/legal-terms
	Organizational Unit: (c) 2014 Entrust, Inc. - for authorized use only
	CommonName: Entrust Certification Authority - L1M
Subject Key ID: D4:17:14:6F:0B:C5:20:A1:D6:FE:21:7E:DC:9E:F8:57:9C:ED:AE:6A
Authority Key ID: C3:F7:D0:B5:2A:30:AD:AF:0D:91:21:70:39:54:DD:BC:89:70:C7:3A
Basic Constraints: CA:false
Key Usage:
	Digital Signature
	Key Encipherment
Extended Key Usage:
	Server Auth
	Client Auth
Alternate DNS Names:
	www.squareup.com, squareup.com, account.squareup.com, mkt.com,
	www.mkt.com, market.squareup.com, gosq.com, www.gosq.com, gosq.co,
	www.gosq.co

** CERTIFICATE 2 **
Serial: 30215777750102225331854468774
Valid: 2014-12-15 15:25 UTC to 2030-10-15 15:55 UTC
Signature: SHA256-RSA
Subject Info:
	Country: US
	Organization: Entrust, Inc.
	Organizational Unit: See www.entrust.net/legal-terms
	Organizational Unit: (c) 2014 Entrust, Inc. - for authorized use only
	CommonName: Entrust Certification Authority - L1M
Issuer Info:
	Country: US
	Organization: Entrust, Inc.
	Organizational Unit: See www.entrust.net/legal-terms
	Organizational Unit: (c) 2009 Entrust, Inc. - for authorized use only
	CommonName: Entrust Root Certification Authority - G2
Subject Key ID: C3:F7:D0:B5:2A:30:AD:AF:0D:91:21:70:39:54:DD:BC:89:70:C7:3A
Authority Key ID: 6A:72:26:7A:D0:1E:EF:7D:E7:3B:69:51:D4:6C:8D:9F:90:12:66:AB
Basic Constraints: CA:true, pathlen:0
Key Usage:
	Cert Sign
	CRL Sign
Extended Key Usage:
	Client Auth
	Server Auth

** CERTIFICATE 3 **
Serial: 1372799044
Valid: 2014-09-22 17:14 UTC to 2024-09-23 01:31 UTC
Signature: SHA256-RSA
Subject Info:
	Country: US
	Organization: Entrust, Inc.
	Organizational Unit: See www.entrust.net/legal-terms
	Organizational Unit: (c) 2009 Entrust, Inc. - for authorized use only
	CommonName: Entrust Root Certification Authority - G2
Issuer Info:
	Country: US
	Organization: Entrust, Inc.
	Organizational Unit: www.entrust.net/CPS is incorporated by reference
	Organizational Unit: (c) 2006 Entrust, Inc.
	CommonName: Entrust Root Certification Authority
Subject Key ID: 6A:72:26:7A:D0:1E:EF:7D:E7:3B:69:51:D4:6C:8D:9F:90:12:66:AB
Authority Key ID: 68:90:E4:67:A4:A6:53:80:C7:86:66:A4:F1:F7:4B:43:FB:84:BD:6D
Basic Constraints: CA:true, pathlen:1
Key Usage:
	Cert Sign
	CRL Sign

Found 2 valid certificate chain(s):
[0] www.squareup.com
	=> Entrust Certification Authority - L1M
	=> Entrust Root Certification Authority - G2 [self-signed]
[1] www.squareup.com
	=> Entrust Certification Authority - L1M
	=> Entrust Root Certification Authority - G2
	=> Entrust Root Certification Authority [self-signed] [SHA1-RSA]

Advanced examples on how to combine JSON output with jq filtering:

# Find certificates that have linter warnings
certigo dump --json $INPUT | jq '.certificates[] | select(.lints != [])'

# Find certificates that are signed with SHA1-RSA
certigo dump --json $INPUT | jq '.certificates[] | select(.signature_algorithm == "SHA1-RSA")'

# List all Common Names of certificates that are expired
certigo dump --json $INPUT | jq -r '.certificates[] | select(.not_after < now) | .subject.common_name'

# Look for MySQL servers with invalid certificates
for SERVER in $(cat servers); do
  certigo connect -t mysql -j $SERVER:3306 | jq -e '.verify_result.error != null' >/dev/null
  if [ $? -ne 0 ]; then
    echo "Invalid certificates on $SERVER"
  fi
done

# Find (redundant) self-signed certificates in intermediate chain on remote host
certigo connect --json $SERVER:$PORT | jq -e '.certificates[1:][] | select(.is_self_signed) | .subject.common_name'

# Test if server is requesting that clients send certificates for authentication
certigo connect --json $SERVER:$PORT | jq -e '.certificate_request_info != null'

certigo's People

Contributors

0xflotus avatar albertoeks avatar alokmenghrajani avatar bbkane avatar captiosus avatar christodenny avatar codelingobot avatar cpilsworth avatar csstaub avatar dependabot-preview[bot] avatar dependabot[bot] avatar elyscape avatar isemaya-square avatar jason-riddle avatar jdtw avatar john-shieh avatar klyubin avatar mbyczkowski avatar mcpherrinm avatar nealharris avatar nicktrav avatar rjchee avatar seththeriault avatar vaporup avatar violetd12 avatar worldwise001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

certigo's Issues

Automatically try "well known" passwords

Many java trust stores are "protected" with the default password changeit. Password protection often provides little value when the files are protected, perhaps in a secrets management system.

Other passwords I have seen from a github search for "keytool storepass" and we could guess:

changeit
changeme
keystore
CHANGE
ponies
ez24get
storepass
Storepass
password
passphrase
secret
123456

help

20161207085958

it is not work

Better trust chain output

Today, we dump all built trust chains.

That could be improved in a few ways:

  • Don't print all of them out unless in --verbose
  • Warn about un-needed intermediates (but be careful; they may be needed with other trust stores)
  • Warn about un-needed roots served in trust chains
  • some support for pinning leafs / intermediates

OpenSSL doesn't support PEM headers

We currently print PEM headers when the --pem flag is passed with extra information, e.g. the friendly name of an entry in a PKCS12 keystore. However, OpenSSL can't handle these and will refuse to parse them. We should consider scrubbing headers on PEM output.

SNI and redirects

Is there a way to verify a cert chain if the site is sitting behind some sort of LB that is using SNI or is doing a redirect?

Two examples, heise.de and oglaf.com.

certigo connect heise.de:443

** TLS Connection **
Version: TLS 1.2
Cipher Suite: ECDHE_RSA key exchange, AES_128_GCM_SHA256 cipher

** CERTIFICATE 1 **
Valid: 2017-10-08 21:20 UTC to 2018-01-06 21:20 UTC
Subject: CN=redirector.heise.de
Issuer: CN=Let's Encrypt Authority X3
DNS Names:
	redirector.heise.de

** CERTIFICATE 2 **
Valid: 2016-03-17 16:40 UTC to 2021-03-17 16:40 UTC
Subject: CN=Let's Encrypt Authority X3
Issuer: CN=DST Root CA X3

Failed to verify certificate chain:
	x509: certificate is valid for redirector.heise.de, not heise.de
certigo connect oglaf.com:443

** TLS Connection **
Version: TLS 1.2
Cipher Suite: ECDHE_RSA key exchange, AES_128_GCM_SHA256 cipher

** CERTIFICATE 1 **
Valid: 2015-08-11 18:24 UTC to 2025-08-08 18:24 UTC
Subject: CN=sni.dreamhost.com
Issuer: CN=sni.dreamhost.com
Warnings:
	Certificate doesn't have any valid DNS/URI names or IP addresses set

Failed to verify certificate chain:
	x509: certificate is valid for sni.dreamhost.com, not oglaf.com

Print warning if cert is using outdated X.509 version

Certificates should be in X.509 version 3 format. We should print a warning if we encounter a certificate that is in an old format (X.509 versions 1 or 2). Note that the "version" tag in the certificate is zero-indexed, i.e. 0/1/2.

Attempting to verify a CSR causes panic: runtime error: index out of range

% certigo verify --name=REDACTED -f pem server2019.csr 
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/square/certigo/lib.VerifyChain(0xc62e38, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7ffc75d487a2, 0x18, 0x0, 0x0, ...)
        /home/meta/go/src/github.com/square/certigo/lib/verify.go:129 +0x8e3
main.main()
        /home/meta/go/src/github.com/square/certigo/main.go:183 +0x1033

Hide empty fields in output

Hide empty fields in dump output, e.g. empty subject fields or missing key idents:

Subject Info:
    CommonName: *.google.com
    Organization: [Google Inc]
    OrganizationalUnit: []
    Country: [US]
    Locality: [Mountain View]

Organizational unit doesn't need to be in the output if it's empty.

Subject Key ID  :
Authority Key ID:

If key idents are missing we can elide the output.

Print warning if using small key

We should show a warning if we encounter a certificate that is using a key that's too small (e.g. 1024-bit for RSA keys, or 160-bit for ECC keys).

Better output for multiple certificates

Right now, the output is a bit confusing if a file contains multiple certificates.

For example:

$ ./certigo dump --format PEM certs/cert.pem
Not Before: 2016-05-27 21:15:31 +0000 UTC
Not After : 2017-10-09 21:15:31 +0000 UTC
Signature algorithm: SHA1-RSA
Subject Info:
    CommonName: ApertureScience
    Organization: [Aperture Science]
    OrganizationalUnit: [Research and Development]
    Country: [US]
    Locality: [San Francisco]
Issuer Info:
    CommonName: ApertureScience
    Organization: [Aperture Science]
    OrganizationalUnit: [Research and Development]
    Country: [US]
    Locality: [San Francisco]
Subject Key ID  :
Authority Key ID:
Alternate DNS Names: []
Serial Number: 11578389349061131131
Not Before: 2016-05-27 21:15:31 +0000 UTC
Not After : 2017-10-09 21:15:31 +0000 UTC
Signature algorithm: SHA1-RSA
Subject Info:
    CommonName: ApertureScience
    Organization: [Aperture Science]
    OrganizationalUnit: [Research and Development]
    Country: [US]
    Locality: [San Francisco]
Issuer Info:
    CommonName: ApertureScience
    Organization: [Aperture Science]
    OrganizationalUnit: [Research and Development]
    Country: [US]
    Locality: [San Francisco]
Subject Key ID  :
Authority Key ID:
Alternate DNS Names: []
Serial Number: 11578389349061131131

It's not clear at first sight that those are two certificates in one file.

Building certigo with Go tip can cause panics with 'certigo connect' in certigo/lib.explainCipher

The illustration and reproduction:

$ certigo connect www.google.com:https
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/square/certigo/lib.explainCipher(0xc00035e3e0, 0xc, 0xc00035e3e0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /homes/hawklords/cks/go/src/github.com/square/certigo/lib/tls.go:182 +0x1e3
github.com/square/certigo/lib.EncodeTLSInfoToText(0xc0001222c0, 0x0, 0x2, 0x0)
        /homes/hawklords/cks/go/src/github.com/square/certigo/lib/tls.go:62 +0x148
main.main()
        /homes/hawklords/cks/go/src/github.com/square/certigo/main.go:162 +0x667

The problem is that explainCipher() has a hard-coded list of ciphers and it assumes that this list covers all ciphers that Go's TLS code can ever use. In Go tip, the list of supported TLS ciphers has expanded (to include TLS 1.3 ciphers, such as TLS_AES_128_GCM_SHA256, which is what I believe is being negociated here), but the cipher is not in the list and so explainCipher winds up trying to slice up a null string and creating a bad index.

One fix would be to add the new Go supported ciphers to the list. This is a bit tricky, since their tls. values are not defined in current released Go versions, so they would have to be added by explicit hex value with comments. Another would be to make explainCipher cope (somehow) with ciphers not in the cipherSuites map.

(I believe that there is probably a similar issue with the tlsVersions map, which currently doesn't include TLS 1.3.)

The build issue might be dealt with by pulling both tlsVersions and cipherSuites out into multiple separate files, each built only on Go versions with the necessary constants defined.

(It is a real pity that crypto/tls does not export any name mapping information in its public API, because it sticks programs and code like this with a tough job and a tough set of tradeoffs. But I assume that the Go authors have their reasons.)

Explicitly print if cert is self-signed in non-verbose mode

Right now, a root appears as something like this:

Serial: 927650371
Valid: 1999-05-25 16:09 UTC to 2019-05-25 16:39 UTC
Signature: SHA1-RSA (self-signed)
Subject Info:
	Country: US
	Organization: Entrust.net
	Organizational Unit: www.entrust.net/CPS incorp. by ref. (limits liab.)
	Organizational Unit: (c) 1999 Entrust.net Limited
	CommonName: Entrust.net Secure Server Certification Authority
Issuer Info:
	Country: US
	Organization: Entrust.net
	Organizational Unit: www.entrust.net/CPS incorp. by ref. (limits liab.)
	Organizational Unit: (c) 1999 Entrust.net Limited
	CommonName: Entrust.net Secure Server Certification Authority
Subject Key ID: F0:17:62:13:55:3D:B3:FF:0A:00:6B:FB:50:84:97:F3:ED:62:D0:1A
Authority Key ID: F0:17:62:13:55:3D:B3:FF:0A:00:6B:FB:50:84:97:F3:ED:62:D0:1A
Basic Constraints: CA:true
Key Usage:
	Cert Sign
	CRL Sign
Warnings:
	Size of RSA key should be at least 2048 bits
	Signed with SHA1-RSA, which is an outdated signature algorithm

We print (self-signed) next to the signature if it's self-signed.
However, we still print an issuer, repeating all the information from the subject, which since it's self-signed must be the same.

In non-verbose mode, we don't print anything at all indicating it's self-signed.

I propose we change the Issuer Info: field to say something like:

Issuer Info:
	Self-signed

when the certificate is self-signed, in both verbose and non-verbose modes.

No changes to JSON are needed, as it always has a "is_self_signed": true, field, though we could omit the issuer information in that case, but there's no real need to change that.

Better output for certs with a lot of subject alt names

Improve output for certs with a lot of subject alt names.

For example, this is what google.com's current cert shows (note the many SANs):

$ ./certigo dump certs/google.com.pem
Enable Date: 2016-05-25 15:03:23 +0000 UTC
Expiry Date: 2016-08-17 14:42:00 +0000 UTC
Algorithm Type: SHA256-RSA
Subject Info:
    CommonName: *.google.com
    Organization: [Google Inc]
    OrganizationalUnit: []
    Country: [US]
    Locality: [Mountain View]
Issuer Info:
    CommonName: Google Internet Authority G2
    Organization: [Google Inc]
    OrganizationalUnit: []
    Country: [US]
    Locality: []
Subject Key ID  : 7C:D4:C5:48:38:F5:22:2C:4B:20:AA:B1:BD:A1:08:CA:B6:4B:6E:3C
Authority Key ID: 4A:DD:06:16:1B:BC:F6:68:B5:76:F5:81:B6:BB:62:1A:BA:5A:81:2F
Alternate DNS Names: [*.google.com *.android.com *.appengine.google.com *.cloud.google.com *.google-analytics.com *.google.ca *.google.cl *.google.co.in *.google.co.jp *.google.co.uk *.google.com.ar *.google.com.au *.google.com.br *.google.com.co *.google.com.mx *.google.com.tr *.google.com.vn *.google.de *.google.es *.google.fr *.google.hu *.google.it *.google.nl *.google.pl *.google.pt *.googleadapis.com *.googleapis.cn *.googlecommerce.com *.googlevideo.com *.gstatic.cn *.gstatic.com *.gvt1.com *.gvt2.com *.metric.gstatic.com *.urchin.com *.url.google.com *.youtube-nocookie.com *.youtube.com *.youtubeeducation.com *.ytimg.com android.clients.google.com android.com g.co goo.gl google-analytics.com google.com googlecommerce.com urchin.com www.goo.gl youtu.be youtube.com youtubeeducation.com]
Serial Number: 9101476628582717928

Enhancement: support SMTP STARTTLS with an EHLO name other than 'localhost'

The Go net/smtp package that certigo's starttls.GetConnectionState uses defaults to EHLO'ing with the name localhost. Unfortunately not all SMTP servers accept this EHLO name; since it's frequently abused by bad clients, it's also frequently rejected, which hampers using certigo connect -t smtp ... to obtain TLS certificate information from various SMTP servers.

The official way to supply a non-localhost name is to explicitly call smtp.Hello() immediately after connecting (before you do anything else). Probably the simplest approach here is to add an extra command line argument to specify the EHLO name to use, since this avoids the morass of trying to automatically determine a plausible host name for the connection.

Support BER input

Go can't process BER input, only DER. Would be nice to have a preprocessing step that canonicalizes any BER into DER.

Set up Travis-CI for testing

Once we have unit/integration tests, we should set up travis-ci.org for automated testing. Depends on issue #19. Also neat: coveralls for code coverage information.

Support JKS stores

The documentation indicates that certigo supports both JKS and JCEKS keystore files, but it appears to only support JCEKS files:

scapeless:jkstest elyscape$ keytool -genkeypair -keystore keystore.jks -storepass password -keypass password -alias selfsigned -keyalg RSA -keysize 2048 -validity 365 -dname CN=selfsigned
scapeless:jkstest elyscape$ certigo dump keystore.jks -p password
scapeless:jkstest elyscape$ certigo dump keystore.jks -p password -j
{"certificates":[]}
scapeless:jkstest elyscape$ keytool -list -keystore keystore.jks -storepass password

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

selfsigned, Mar 15, 2017, PrivateKeyEntry, 
Certificate fingerprint (SHA1): F5:38:97:C4:D9:78:7C:0D:A8:12:1A:7E:C8:EE:28:3C:5F:22:5A:CB

By contrast, if I convert the same keystore into a JCEKS file:

scapeless:jkstest elyscape$ keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.jceks -deststoretype JCEKS -srcstorepass password -deststorepass password
Entry for alias selfsigned successfully imported.
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled
scapeless:jkstest elyscape$ certigo dump keystore.jceks -p password
** CERTIFICATE 1 **
Valid: 2017-03-15 18:29 UTC to 2018-03-15 18:29 UTC
Subject: CN=selfsigned
Issuer: CN=selfsigned

I created the keystore files using the version of keytool provided with Java 1.8u112:

scapeless:jkstest elyscape$ java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

If you want to test with the keystore files I generated here, I've attached them in this zip file.

Panic in certigo/lib.explainCipher

❯❯❯ certigo connect <redacted>
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/square/certigo/lib.explainCipher(0xc00002a960, 0xc, 0xc00002a960, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/certigo-20200106-25422-1jnrsi9/certigo-1.11.0/lib/tls.go:182 +0x1e3
github.com/square/certigo/lib.EncodeTLSInfoToText(0xc0001a80b0, 0x0, 0x5, 0x0)
	/private/tmp/certigo-20200106-25422-1jnrsi9/certigo-1.11.0/lib/tls.go:62 +0x148
main.main()
	/private/tmp/certigo-20200106-25422-1jnrsi9/certigo-1.11.0/main.go:162 +0x667

This happened on a new AWS Classic LB, haven't been able to consistently reproduce.

Feature request: An option for terser output from at least 'certigo connect'

certigo connect is awesome for providing detailed information about the TLS certificate and certificate chain actively being used by a service. But sometimes displaying all that information is overkill, and what I really want to know is basic information about the certificate, the certificate chain, and the validity of the whole chain. So, this is a feature request for some sort of 'terse' flag for at least certigo connect that would produce terser output. If this is a feature that would be accepted for certigo, I'd be happy to see if I can do at least a preliminary implementation.

What should be included in terse output is certainly an open question. What I think I would find most useful is:

  • TLS version and cipher suite
  • the DNS names covered between the certificate's CN and alternate DNS names
  • the certificate's not before and not after dates
  • the shortest valid certificate chain (possibly with not-after dates for each chained certificate)

A more feature-rich 'terse output' implementation might provide additional options to control some of these, but that might be best done in separate enhancements.

Warn on incorrect password (p12 files)

./certigo dump < certs/certWithPassword.p12 with an incorrect password simply exits. We should show an error message, similar to when handling jceks files.

Show format

Certigo should output what format the tool guessed. It can help when debugging issues with other tools and/or with certigo itself.

Expose list of supported formats

It seems users currently have to guess (or look at the source code) to figure out the set of valid formats.

We should improve the output of certigo dump --help. We could also list all the valid formats when an invalid one is provided (currently, we only return unknown file type: xyz).

Add an option to verify on connect

One thing I've been using certigo for is to validate that our systems have proper SSL certificates installed (since we're using an internal CA). The "problem" is that certigo connect will show whether there are issues with the certificate, but it exits with a 0 regardless.

For instance:

$ certigo connect --name xxx github.com:443  
** TLS Connection **
.....
Failed to verify certificate chain:
        x509: certificate is valid for github.com, www.github.com, not xxx
$ echo $?
0

vs

$ certigo connect --pem github.com:443 | certigo verify --name xxx
Failed to verify certificate chain:
        x509: certificate is valid for github.com, www.github.com, not xxx
$ echo $?
1

It would be useful for connect to have an option like --verify that fails if the certificate is invalid.

Add lint command

Instead of showing warnings on dump, we should add a "lint" command that checks for things like in #13, #14, #15, etc.

Ship well-known CA bundles in Certigo

It can be useful to diagnose connectivity problems.

We could then alert if trust status is different in various bundles.

EG: a warning like not trusted in Windows XP, Centos 6; trusted by Windows 10, Centos 7, Apple

More STARTTLS Protocols

Here's a list of STARTTLS type protocols I've found:

Many of these are simple text protocols, and we can probably get away with a very simple client that talks just enough to get to the STARTTLS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.