| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 X509Certificate* X509Certificate::CreateFromBytes(const char* data, | 162 X509Certificate* X509Certificate::CreateFromBytes(const char* data, |
| 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), source_(source) { | 172 : cert_handle_(cert_handle), |
| 173 #if defined(OS_MACOSX) |
| 174 intermediate_ca_certs_(NULL), |
| 175 #endif |
| 176 source_(source) { |
| 173 Initialize(); | 177 Initialize(); |
| 174 } | 178 } |
| 175 | 179 |
| 176 X509Certificate::X509Certificate(const std::string& subject, | 180 X509Certificate::X509Certificate(const std::string& subject, |
| 177 const std::string& issuer, | 181 const std::string& issuer, |
| 178 base::Time start_date, | 182 base::Time start_date, |
| 179 base::Time expiration_date) | 183 base::Time expiration_date) |
| 180 : subject_(subject), | 184 : subject_(subject), |
| 181 issuer_(issuer), | 185 issuer_(issuer), |
| 182 valid_start_(start_date), | 186 valid_start_(start_date), |
| 183 valid_expiry_(expiration_date), | 187 valid_expiry_(expiration_date), |
| 184 cert_handle_(NULL), | 188 cert_handle_(NULL), |
| 189 #if defined(OS_MACOSX) |
| 190 intermediate_ca_certs_(NULL), |
| 191 #endif |
| 185 source_(SOURCE_UNUSED) { | 192 source_(SOURCE_UNUSED) { |
| 186 memset(fingerprint_.data, 0, sizeof(fingerprint_.data)); | 193 memset(fingerprint_.data, 0, sizeof(fingerprint_.data)); |
| 187 } | 194 } |
| 188 | 195 |
| 189 X509Certificate::~X509Certificate() { | 196 X509Certificate::~X509Certificate() { |
| 190 // We might not be in the cache, but it is safe to remove ourselves anyway. | 197 // We might not be in the cache, but it is safe to remove ourselves anyway. |
| 191 X509Certificate::Cache::GetInstance()->Remove(this); | 198 X509Certificate::Cache::GetInstance()->Remove(this); |
| 192 if (cert_handle_) | 199 if (cert_handle_) |
| 193 FreeOSCertHandle(cert_handle_); | 200 FreeOSCertHandle(cert_handle_); |
| 201 #if defined(OS_MACOSX) |
| 202 if (intermediate_ca_certs_) |
| 203 CFRelease(intermediate_ca_certs_); |
| 204 #endif |
| 194 } | 205 } |
| 195 | 206 |
| 196 bool X509Certificate::HasExpired() const { | 207 bool X509Certificate::HasExpired() const { |
| 197 return base::Time::Now() > valid_expiry(); | 208 return base::Time::Now() > valid_expiry(); |
| 198 } | 209 } |
| 199 | 210 |
| 200 } // namespace net | 211 } // namespace net |
| OLD | NEW |