| 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 <string> | 5 #include <string> |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return NULL; | 73 return NULL; |
| 74 } | 74 } |
| 75 | 75 |
| 76 LOG(INFO) << "Loaded temporary certificate " << filename.ToWStringHack(); | 76 LOG(INFO) << "Loaded temporary certificate " << filename.ToWStringHack(); |
| 77 return cert; | 77 return cert; |
| 78 } | 78 } |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 SSLTestUtil::SSLTestUtil() { | 81 SSLTestUtil::SSLTestUtil() { |
| 82 PathService::Get(base::DIR_SOURCE_ROOT, &cert_dir_); | 82 PathService::Get(base::DIR_SOURCE_ROOT, &cert_dir_); |
| 83 cert_dir_ = cert_dir_.Append(FILE_PATH_LITERAL("net")); | 83 cert_dir_ = cert_dir_.AppendASCII("net"); |
| 84 cert_dir_ = cert_dir_.Append(FILE_PATH_LITERAL("data")); | 84 cert_dir_ = cert_dir_.AppendASCII("data"); |
| 85 cert_dir_ = cert_dir_.Append(FILE_PATH_LITERAL("ssl")); | 85 cert_dir_ = cert_dir_.AppendASCII("ssl"); |
| 86 cert_dir_ = cert_dir_.Append(FILE_PATH_LITERAL("certificates")); | 86 cert_dir_ = cert_dir_.AppendASCII("certificates"); |
| 87 | 87 |
| 88 #if defined(OS_LINUX) | 88 #if defined(OS_LINUX) |
| 89 cert_ = reinterpret_cast<PrivateCERTCertificate*>( | 89 cert_ = reinterpret_cast<PrivateCERTCertificate*>( |
| 90 LoadTemporaryCert(GetRootCertPath())); | 90 LoadTemporaryCert(GetRootCertPath())); |
| 91 DCHECK(cert_); | 91 DCHECK(cert_); |
| 92 #endif | 92 #endif |
| 93 } | 93 } |
| 94 | 94 |
| 95 SSLTestUtil::~SSLTestUtil() { | 95 SSLTestUtil::~SSLTestUtil() { |
| 96 #if defined(OS_LINUX) | 96 #if defined(OS_LINUX) |
| 97 if (cert_) | 97 if (cert_) |
| 98 CERT_DestroyCertificate(reinterpret_cast<CERTCertificate*>(cert_)); | 98 CERT_DestroyCertificate(reinterpret_cast<CERTCertificate*>(cert_)); |
| 99 #endif | 99 #endif |
| 100 } | 100 } |
| 101 | 101 |
| 102 FilePath SSLTestUtil::GetRootCertPath() { | 102 FilePath SSLTestUtil::GetRootCertPath() { |
| 103 FilePath path(cert_dir_); | 103 FilePath path(cert_dir_); |
| 104 path = path.Append(FILE_PATH_LITERAL("root_ca_cert.crt")); | 104 path = path.AppendASCII("root_ca_cert.crt"); |
| 105 return path; | 105 return path; |
| 106 } | 106 } |
| 107 | 107 |
| 108 FilePath SSLTestUtil::GetOKCertPath() { | 108 FilePath SSLTestUtil::GetOKCertPath() { |
| 109 FilePath path(cert_dir_); | 109 FilePath path(cert_dir_); |
| 110 path = path.Append(FILE_PATH_LITERAL("ok_cert.pem")); | 110 path = path.AppendASCII("ok_cert.pem"); |
| 111 return path; | 111 return path; |
| 112 } | 112 } |
| 113 | 113 |
| 114 FilePath SSLTestUtil::GetExpiredCertPath() { | 114 FilePath SSLTestUtil::GetExpiredCertPath() { |
| 115 FilePath path(cert_dir_); | 115 FilePath path(cert_dir_); |
| 116 path = path.Append(FILE_PATH_LITERAL("expired_cert.pem")); | 116 path = path.AppendASCII("expired_cert.pem"); |
| 117 return path; | 117 return path; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool SSLTestUtil::CheckCATrusted() { | 120 bool SSLTestUtil::CheckCATrusted() { |
| 121 // TODO(port): Port either this or LoadTemporaryCert to MacOSX. | 121 // TODO(port): Port either this or LoadTemporaryCert to MacOSX. |
| 122 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
| 123 HCERTSTORE cert_store = CertOpenSystemStore(NULL, L"ROOT"); | 123 HCERTSTORE cert_store = CertOpenSystemStore(NULL, L"ROOT"); |
| 124 if (!cert_store) { | 124 if (!cert_store) { |
| 125 LOG(ERROR) << " could not open trusted root CA store"; | 125 LOG(ERROR) << " could not open trusted root CA store"; |
| 126 return false; | 126 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 139 if (!cert) { | 139 if (!cert) { |
| 140 LOG(ERROR) << " TEST CONFIGURATION ERROR: you need to import the test ca " | 140 LOG(ERROR) << " TEST CONFIGURATION ERROR: you need to import the test ca " |
| 141 "certificate to your trusted roots for this test to work. " | 141 "certificate to your trusted roots for this test to work. " |
| 142 "For more info visit:\n" | 142 "For more info visit:\n" |
| 143 "http://dev.chromium.org/developers/testing\n"; | 143 "http://dev.chromium.org/developers/testing\n"; |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 #endif | 146 #endif |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| OLD | NEW |