certigo icon indicating copy to clipboard operation
certigo copied to clipboard

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

Open lpar opened this issue 5 years ago • 6 comments

% 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

lpar avatar Jan 08 '19 21:01 lpar

We don't support verify on cert requests (CSRs) at the moment, only on (issued) certificates. We should probably fix the output/error handling though. Out of curiosity, what kind of verification did you want to do on a CSR?

csstaub avatar Jan 08 '19 22:01 csstaub

I just wanted to double check it was the right one, as I'm juggling TLS updates for a couple of machines right now. I understand it's not supported functionality, just thought you'd want to issue an error rather than crashing :-)

lpar avatar Jan 08 '19 23:01 lpar

I'm seeing the same panic with the connect command:

Command: certigo connect google.com

Result

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/square/certigo/lib.explainCipher(0xc0000cf750, 0xc, 0xc0000cf750, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/certigo-20200106-66700-nqvrn2/certigo-1.11.0/lib/tls.go:182 +0x1e3
github.com/square/certigo/lib.EncodeTLSInfoToText(0xc0001e4000, 0x0, 0x2, 0x0)
	/private/tmp/certigo-20200106-66700-nqvrn2/certigo-1.11.0/lib/tls.go:62 +0x148
main.main()
	/private/tmp/certigo-20200106-66700-nqvrn2/certigo-1.11.0/main.go:162 +0x667

egrieco avatar Feb 18 '20 07:02 egrieco

Is issue #213 related? @siebenmann mentions commit f81df5c as a possible culprit.

egrieco avatar Feb 28 '20 13:02 egrieco

As suggested by @siebenmann, commenting out line 166 resolves the error for me.

cli/cli.go:166 fmt.Fprintf(stdout, "Input Format: %s\n", result.Formats[i])

egrieco avatar Feb 28 '20 14:02 egrieco

@egrieco yes, the issue is related and we will track it in #213. Thanks!

mbyczkowski avatar Feb 28 '20 18:02 mbyczkowski