OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cert.h> | 7 #include <cert.h> |
8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <nss.h> | 10 #include <nss.h> |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 cert->default_nickname_ = nickname; | 703 cert->default_nickname_ = nickname; |
704 | 704 |
705 return cert; | 705 return cert; |
706 } | 706 } |
707 | 707 |
708 std::string X509Certificate::GetDefaultNickname(CertType type) const { | 708 std::string X509Certificate::GetDefaultNickname(CertType type) const { |
709 if (!default_nickname_.empty()) | 709 if (!default_nickname_.empty()) |
710 return default_nickname_; | 710 return default_nickname_; |
711 | 711 |
712 std::string result; | 712 std::string result; |
713 if (type == USER_CERT) { | 713 if (type == USER_CERT && cert_handle_->slot) { |
714 // Find the private key for this certificate and see if it has a | 714 // Find the private key for this certificate and see if it has a |
715 // nickname. If there is a private key, and it has a nickname, then | 715 // nickname. If there is a private key, and it has a nickname, then |
716 // we return that nickname. | 716 // we return that nickname. |
717 SECKEYPrivateKey* private_key = PK11_FindPrivateKeyFromCert( | 717 SECKEYPrivateKey* private_key = PK11_FindPrivateKeyFromCert( |
718 cert_handle_->slot, | 718 cert_handle_->slot, |
719 cert_handle_, | 719 cert_handle_, |
720 NULL); // wincx | 720 NULL); // wincx |
721 if (private_key) { | 721 if (private_key) { |
722 char* private_key_nickname = PK11_GetPrivateKeyNickname(private_key); | 722 char* private_key_nickname = PK11_GetPrivateKeyNickname(private_key); |
723 if (private_key_nickname) { | 723 if (private_key_nickname) { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 | 1136 |
1137 // static | 1137 // static |
1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
1139 Pickle* pickle) { | 1139 Pickle* pickle) { |
1140 return pickle->WriteData( | 1140 return pickle->WriteData( |
1141 reinterpret_cast<const char*>(cert_handle->derCert.data), | 1141 reinterpret_cast<const char*>(cert_handle->derCert.data), |
1142 cert_handle->derCert.len); | 1142 cert_handle->derCert.len); |
1143 } | 1143 } |
1144 | 1144 |
1145 } // namespace net | 1145 } // namespace net |
OLD | NEW |