Chromium Code Reviews| 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { |
| 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 if (cert_handle_->slot) { |
|
wtc
2011/12/12 23:52:57
You can merge lines 713 and 717:
if (type == USE
| |
| 718 cert_handle_->slot, | 718 SECKEYPrivateKey* private_key = PK11_FindPrivateKeyFromCert( |
| 719 cert_handle_, | 719 cert_handle_->slot, |
| 720 NULL); // wincx | 720 cert_handle_, |
| 721 if (private_key) { | 721 NULL); // wincx |
| 722 char* private_key_nickname = PK11_GetPrivateKeyNickname(private_key); | 722 if (private_key) { |
| 723 if (private_key_nickname) { | 723 char* private_key_nickname = PK11_GetPrivateKeyNickname(private_key); |
| 724 result = private_key_nickname; | 724 if (private_key_nickname) { |
| 725 PORT_Free(private_key_nickname); | 725 result = private_key_nickname; |
| 726 PORT_Free(private_key_nickname); | |
| 727 SECKEY_DestroyPrivateKey(private_key); | |
| 728 return result; | |
| 729 } | |
| 726 SECKEY_DestroyPrivateKey(private_key); | 730 SECKEY_DestroyPrivateKey(private_key); |
| 727 return result; | |
| 728 } | 731 } |
| 729 SECKEY_DestroyPrivateKey(private_key); | |
| 730 } | 732 } |
| 731 } | 733 } |
| 732 | 734 |
| 733 switch (type) { | 735 switch (type) { |
| 734 case CA_CERT: { | 736 case CA_CERT: { |
| 735 char* nickname = CERT_MakeCANickname(cert_handle_); | 737 char* nickname = CERT_MakeCANickname(cert_handle_); |
| 736 result = nickname; | 738 result = nickname; |
| 737 PORT_Free(nickname); | 739 PORT_Free(nickname); |
| 738 break; | 740 break; |
| 739 } | 741 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 | 1138 |
| 1137 // static | 1139 // static |
| 1138 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 1140 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
| 1139 Pickle* pickle) { | 1141 Pickle* pickle) { |
| 1140 return pickle->WriteData( | 1142 return pickle->WriteData( |
| 1141 reinterpret_cast<const char*>(cert_handle->derCert.data), | 1143 reinterpret_cast<const char*>(cert_handle->derCert.data), |
| 1142 cert_handle->derCert.len); | 1144 cert_handle->derCert.len); |
| 1143 } | 1145 } |
| 1144 | 1146 |
| 1145 } // namespace net | 1147 } // namespace net |
| OLD | NEW |