Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: net/cert/x509_certificate_nss.cc

Issue 634033002: Check whether or not a certificate is self-signed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS implementation. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cert/x509_certificate_nss.cc
diff --git a/net/cert/x509_certificate_nss.cc b/net/cert/x509_certificate_nss.cc
index a57f9ce71f200914bb7a597be57ac70073d410c3..1d657597719a039cfb1a302d8acf7397ca14f829 100644
--- a/net/cert/x509_certificate_nss.cc
+++ b/net/cert/x509_certificate_nss.cc
@@ -281,4 +281,13 @@ void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
x509_util::GetPublicKeyInfo(cert_handle, size_bits, type);
}
+// static
+bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) {
+ SECKEYPublicKey* public_key = CERT_ExtractPublicKey(cert_handle);
Ryan Sleevi 2014/10/27 23:33:13 BUG: You're leaking this
palmer 2014/10/28 23:13:41 Done.
+ if (!public_key)
+ return false;
+ return SECSuccess == CERT_VerifySignedDataWithPublicKey(
+ &cert_handle->signatureWrap, public_key, NULL);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698