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

Unified Diff: net/cert/x509_certificate_mac.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « net/cert/x509_certificate_ios.cc ('k') | net/cert/x509_certificate_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/x509_certificate_mac.cc
diff --git a/net/cert/x509_certificate_mac.cc b/net/cert/x509_certificate_mac.cc
index ecdf137c40c240e8ef3818db6e2e8b3a685bbf6b..f8bfe12c71489915be70dd5babe7313198791862 100644
--- a/net/cert/x509_certificate_mac.cc
+++ b/net/cert/x509_certificate_mac.cc
@@ -531,4 +531,41 @@ void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
}
}
+// static
+bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) {
+ x509_util::CSSMCachedCertificate cached_cert;
+ OSStatus status = cached_cert.Init(cert_handle);
+ if (status != noErr)
+ return false;
+
+ x509_util::CSSMFieldValue subject;
+ status = cached_cert.GetField(&CSSMOID_X509V1SubjectNameStd, &subject);
+ if (status != CSSM_OK || !subject.field())
+ return false;
+
+ x509_util::CSSMFieldValue issuer;
+ status = cached_cert.GetField(&CSSMOID_X509V1IssuerNameStd, &issuer);
+ if (status != CSSM_OK || !issuer.field())
+ return false;
+
+ if (subject.field()->Length != issuer.field()->Length ||
+ memcmp(subject.field()->Data, issuer.field()->Data,
+ issuer.field()->Length) != 0) {
+ return false;
+ }
+
+ CSSM_CL_HANDLE cl_handle = CSSM_INVALID_HANDLE;
+ status = SecCertificateGetCLHandle(cert_handle, &cl_handle);
+ if (status)
+ return false;
+ CSSM_DATA cert_data;
+ status = SecCertificateGetData(cert_handle, &cert_data);
+ if (status)
+ return false;
+
+ if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0))
+ return false;
+ return true;
+}
+
} // namespace net
« no previous file with comments | « net/cert/x509_certificate_ios.cc ('k') | net/cert/x509_certificate_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698