@@ -90,9 +90,14 @@ func ixHandshakeStage1(f *Interface, addr *udp.Addr, via *ViaSender, packet []by
90
90
91
91
remoteCert , err := RecombineCertAndValidate (ci .H , hs .Details .Cert , f .pki .GetCAPool ())
92
92
if err != nil {
93
- f .l .WithError (err ).WithField ("udpAddr" , addr ).
94
- WithField ("handshake" , m {"stage" : 1 , "style" : "ix_psk0" }).WithField ("cert" , remoteCert ).
95
- Info ("Invalid certificate from host" )
93
+ e := f .l .WithError (err ).WithField ("udpAddr" , addr ).
94
+ WithField ("handshake" , m {"stage" : 1 , "style" : "ix_psk0" })
95
+
96
+ if f .l .Level > logrus .DebugLevel {
97
+ e = e .WithField ("cert" , remoteCert )
98
+ }
99
+
100
+ e .Info ("Invalid certificate from host" )
96
101
return
97
102
}
98
103
vpnIp := iputil .Ip2VpnIp (remoteCert .Details .Ips [0 ].IP )
@@ -372,9 +377,14 @@ func ixHandshakeStage2(f *Interface, addr *udp.Addr, via *ViaSender, hh *Handsha
372
377
373
378
remoteCert , err := RecombineCertAndValidate (ci .H , hs .Details .Cert , f .pki .GetCAPool ())
374
379
if err != nil {
375
- f .l .WithError (err ).WithField ("vpnIp" , hostinfo .vpnIp ).WithField ("udpAddr" , addr ).
376
- WithField ("cert" , remoteCert ).WithField ("handshake" , m {"stage" : 2 , "style" : "ix_psk0" }).
377
- Error ("Invalid certificate from host" )
380
+ e := f .l .WithError (err ).WithField ("vpnIp" , hostinfo .vpnIp ).WithField ("udpAddr" , addr ).
381
+ WithField ("handshake" , m {"stage" : 2 , "style" : "ix_psk0" })
382
+
383
+ if f .l .Level > logrus .DebugLevel {
384
+ e = e .WithField ("cert" , remoteCert )
385
+ }
386
+
387
+ e .Error ("Invalid certificate from host" )
378
388
379
389
// The handshake state machine is complete, if things break now there is no chance to recover. Tear down and start again
380
390
return true
0 commit comments