crypto: clear error in GetPeerCertificate

fix #6945
Merge remote-tracking branch 'upstream/master'