summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2020-08-07 12:12:29 -0600
committerGitHub <noreply@github.com>2020-08-07 12:12:29 -0600
commit65a09524c3926547ed0b8515da211173df4fe379 (patch)
treeba1b373fe54589608ad15c36cfe48137872d25f9
parentc6d6a775a18999d7594d7656476405a582b3f8ab (diff)
caddyhttp: Add TLS client cert info to logs (#3640)
-rw-r--r--modules/caddyhttp/marshalers.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/caddyhttp/marshalers.go b/modules/caddyhttp/marshalers.go
index 7f95923..9e8bb9f 100644
--- a/modules/caddyhttp/marshalers.go
+++ b/modules/caddyhttp/marshalers.go
@@ -73,10 +73,14 @@ type LoggableTLSConnState tls.ConnectionState
func (t LoggableTLSConnState) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddBool("resumed", t.DidResume)
enc.AddUint16("version", t.Version)
- enc.AddUint16("ciphersuite", t.CipherSuite)
+ enc.AddUint16("cipher_suite", t.CipherSuite)
enc.AddString("proto", t.NegotiatedProtocol)
enc.AddBool("proto_mutual", t.NegotiatedProtocolIsMutual)
enc.AddString("server_name", t.ServerName)
+ if len(t.PeerCertificates) > 0 {
+ enc.AddString("client_common_name", t.PeerCertificates[0].Subject.CommonName)
+ enc.AddString("client_serial", t.PeerCertificates[0].SerialNumber.String())
+ }
return nil
}