| 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 "base/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 | 10 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 int length) { | 163 int length) { |
| 164 OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); | 164 OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); |
| 165 if (!cert_handle) | 165 if (!cert_handle) |
| 166 return NULL; | 166 return NULL; |
| 167 | 167 |
| 168 return CreateFromHandle(cert_handle, SOURCE_LONE_CERT_IMPORT); | 168 return CreateFromHandle(cert_handle, SOURCE_LONE_CERT_IMPORT); |
| 169 } | 169 } |
| 170 | 170 |
| 171 X509Certificate::X509Certificate(OSCertHandle cert_handle, Source source) | 171 X509Certificate::X509Certificate(OSCertHandle cert_handle, Source source) |
| 172 : cert_handle_(cert_handle), | 172 : cert_handle_(cert_handle), |
| 173 #if defined(OS_MACOSX) | |
| 174 intermediate_ca_certs_(NULL), | |
| 175 #endif | |
| 176 source_(source) { | 173 source_(source) { |
| 177 Initialize(); | 174 Initialize(); |
| 178 } | 175 } |
| 179 | 176 |
| 180 X509Certificate::X509Certificate(const std::string& subject, | 177 X509Certificate::X509Certificate(const std::string& subject, |
| 181 const std::string& issuer, | 178 const std::string& issuer, |
| 182 base::Time start_date, | 179 base::Time start_date, |
| 183 base::Time expiration_date) | 180 base::Time expiration_date) |
| 184 : subject_(subject), | 181 : subject_(subject), |
| 185 issuer_(issuer), | 182 issuer_(issuer), |
| 186 valid_start_(start_date), | 183 valid_start_(start_date), |
| 187 valid_expiry_(expiration_date), | 184 valid_expiry_(expiration_date), |
| 188 cert_handle_(NULL), | 185 cert_handle_(NULL), |
| 189 #if defined(OS_MACOSX) | |
| 190 intermediate_ca_certs_(NULL), | |
| 191 #endif | |
| 192 source_(SOURCE_UNUSED) { | 186 source_(SOURCE_UNUSED) { |
| 193 memset(fingerprint_.data, 0, sizeof(fingerprint_.data)); | 187 memset(fingerprint_.data, 0, sizeof(fingerprint_.data)); |
| 194 } | 188 } |
| 195 | 189 |
| 196 X509Certificate::~X509Certificate() { | 190 X509Certificate::~X509Certificate() { |
| 197 // We might not be in the cache, but it is safe to remove ourselves anyway. | 191 // We might not be in the cache, but it is safe to remove ourselves anyway. |
| 198 X509Certificate::Cache::GetInstance()->Remove(this); | 192 X509Certificate::Cache::GetInstance()->Remove(this); |
| 199 if (cert_handle_) | 193 if (cert_handle_) |
| 200 FreeOSCertHandle(cert_handle_); | 194 FreeOSCertHandle(cert_handle_); |
| 201 #if defined(OS_MACOSX) | 195 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 202 if (intermediate_ca_certs_) | 196 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) |
| 203 CFRelease(intermediate_ca_certs_); | 197 FreeOSCertHandle(intermediate_ca_certs_[i]); |
| 204 #endif | 198 #endif |
| 205 } | 199 } |
| 206 | 200 |
| 207 bool X509Certificate::HasExpired() const { | 201 bool X509Certificate::HasExpired() const { |
| 208 return base::Time::Now() > valid_expiry(); | 202 return base::Time::Now() > valid_expiry(); |
| 209 } | 203 } |
| 210 | 204 |
| 211 } // namespace net | 205 } // namespace net |
| OLD | NEW |