OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
6 | 6 |
7 #include <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 #include <Security/Security.h> | 8 #include <Security/Security.h> |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 result = CopyCertChain(os_cert_handle(), &cert_chain); | 865 result = CopyCertChain(os_cert_handle(), &cert_chain); |
866 if (result != noErr) | 866 if (result != noErr) |
867 return false; | 867 return false; |
868 ScopedCFTypeRef<CFArrayRef> scoped_cert_chain(cert_chain); | 868 ScopedCFTypeRef<CFArrayRef> scoped_cert_chain(cert_chain); |
869 | 869 |
870 // Check all the certs in the chain for a match. | 870 // Check all the certs in the chain for a match. |
871 int n = CFArrayGetCount(cert_chain); | 871 int n = CFArrayGetCount(cert_chain); |
872 for (int i = 0; i < n; ++i) { | 872 for (int i = 0; i < n; ++i) { |
873 SecCertificateRef cert_handle = reinterpret_cast<SecCertificateRef>( | 873 SecCertificateRef cert_handle = reinterpret_cast<SecCertificateRef>( |
874 const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, i))); | 874 const_cast<void*>(CFArrayGetValueAtIndex(cert_chain, i))); |
875 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( | 875 scoped_refptr<X509Certificate> cert(X509Certificate::CreateFromHandle( |
876 cert_handle, | 876 cert_handle, |
877 X509Certificate::SOURCE_LONE_CERT_IMPORT, | 877 X509Certificate::SOURCE_LONE_CERT_IMPORT, |
878 X509Certificate::OSCertHandles()); | 878 X509Certificate::OSCertHandles())); |
879 for (unsigned j = 0; j < valid_issuers.size(); j++) { | 879 for (unsigned j = 0; j < valid_issuers.size(); j++) { |
880 if (cert->issuer().Matches(valid_issuers[j])) | 880 if (cert->issuer().Matches(valid_issuers[j])) |
881 return true; | 881 return true; |
882 } | 882 } |
883 } | 883 } |
884 return false; | 884 return false; |
885 } | 885 } |
886 | 886 |
887 // static | 887 // static |
888 OSStatus X509Certificate::CreateSSLClientPolicy(SecPolicyRef* out_policy) { | 888 OSStatus X509Certificate::CreateSSLClientPolicy(SecPolicyRef* out_policy) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 } | 1003 } |
1004 CFRelease(cert_chain); | 1004 CFRelease(cert_chain); |
1005 } | 1005 } |
1006 exit: | 1006 exit: |
1007 if (result) | 1007 if (result) |
1008 LOG(ERROR) << "CreateIdentityCertificateChain error " << result; | 1008 LOG(ERROR) << "CreateIdentityCertificateChain error " << result; |
1009 return chain.release(); | 1009 return chain.release(); |
1010 } | 1010 } |
1011 | 1011 |
1012 } // namespace net | 1012 } // namespace net |
OLD | NEW |