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

Unified Diff: net/base/x509_certificate_mac.cc

Issue 9006041: On OS X, when parsing certificates, properly handle non-ASCII/UTF-8 string types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename GetDistinguishedName to getCertDistinguishedName Created 9 years 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/base/x509_cert_types_mac.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_certificate_mac.cc
diff --git a/net/base/x509_certificate_mac.cc b/net/base/x509_certificate_mac.cc
index 333cd821ef9d5158ad94b1c7e4ff78bbd13b1e84..7d5e0df76ed9d7f2e32c5f54d53b8978411b57b5 100644
--- a/net/base/x509_certificate_mac.cc
+++ b/net/base/x509_certificate_mac.cc
@@ -258,6 +258,17 @@ class CSSMCachedCertificate {
CSSM_HANDLE cached_cert_handle_;
};
+void GetCertDistinguishedName(const CSSMCachedCertificate& cached_cert,
+ const CSSM_OID* oid,
+ CertPrincipal* result) {
+ CSSMFieldValue distinguished_name;
+ OSStatus status = cached_cert.GetField(oid, &distinguished_name);
+ if (status || !distinguished_name.field())
+ return;
+ result->ParseDistinguishedName(distinguished_name.field()->Data,
+ distinguished_name.field()->Length);
+}
+
void GetCertDateForOID(const CSSMCachedCertificate& cached_cert,
const CSSM_OID* oid,
Time* result) {
@@ -677,17 +688,12 @@ void AppendPublicKeyHashes(CFArrayRef chain,
} // namespace
void X509Certificate::Initialize() {
- const CSSM_X509_NAME* name;
- OSStatus status = SecCertificateGetSubject(cert_handle_, &name);
- if (!status)
- subject_.Parse(name);
-
- status = SecCertificateGetIssuer(cert_handle_, &name);
- if (!status)
- issuer_.Parse(name);
-
CSSMCachedCertificate cached_cert;
if (cached_cert.Init(cert_handle_) == CSSM_OK) {
+ GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1SubjectNameStd,
+ &subject_);
+ GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1IssuerNameStd,
+ &issuer_);
GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotBefore,
&valid_start_);
GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotAfter,
« no previous file with comments | « net/base/x509_cert_types_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698