Skip to content

Commit ee00ba3

Browse files
committed
Make sure to print certificaes
1 parent 6a13fa3 commit ee00ba3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

command/tls/handshake.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"encoding/pem"
8+
"errors"
89
"fmt"
910
"net"
1011
"reflect"
@@ -164,6 +165,9 @@ func handshakeAction(c *cli.Context) error {
164165

165166
// Print only the list of verified chains
166167
if printChains {
168+
if len(cs.VerifiedChains) == 0 {
169+
return errors.New("failed to build a chain of verified certificates")
170+
}
167171
for _, chain := range cs.VerifiedChains {
168172
for _, crt := range chain {
169173
fmt.Print(string(pem.EncodeToMemory(&pem.Block{
@@ -177,6 +181,9 @@ func handshakeAction(c *cli.Context) error {
177181

178182
// Print only the peer certificates
179183
if printPeer {
184+
if len(cs.PeerCertificates) == 0 {
185+
return errors.New("peer did not sent a certificate")
186+
}
180187
for _, crt := range cs.PeerCertificates {
181188
fmt.Print(string(pem.EncodeToMemory(&pem.Block{
182189
Type: "CERTIFICATE", Bytes: crt.Raw,

0 commit comments

Comments
 (0)