Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Unified Diff: net/base/x509_certificate_nss.cc

Issue 8566056: This applies GUIDs to certificate and key nicknames when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More review changes Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/x509_certificate_nss.cc
diff --git a/net/base/x509_certificate_nss.cc b/net/base/x509_certificate_nss.cc
index bbb5cef4b656bb88cfcb4bab30323010296f5545..606af5206bb802f5852e524605fb2f45c541708c 100644
--- a/net/base/x509_certificate_nss.cc
+++ b/net/base/x509_certificate_nss.cc
@@ -6,6 +6,7 @@
#include <cert.h>
#include <cryptohi.h>
+#include <keyhi.h>
wtc 2011/12/08 00:07:43 The new code you added doesn't seem to require <ke
Greg Spencer (Chromium) 2011/12/09 18:51:38 Done.
#include <nss.h>
#include <pk11pub.h>
#include <prerror.h>
@@ -666,7 +667,6 @@ void AppendPublicKeyHashes(CERTCertList* cert_list,
}
hashes->push_back(CertPublicKeyHash(root_cert));
}
-
wtc 2011/12/08 00:07:43 Nit: add this blank line back. This matches the b
Greg Spencer (Chromium) 2011/12/09 18:51:38 Done.
} // namespace
void X509Certificate::Initialize() {
@@ -685,6 +685,22 @@ void X509Certificate::Initialize() {
}
// static
+X509Certificate* X509Certificate::CreateFromBytesWithNickname(
+ const char* data,
+ int length,
+ const char* nickname) {
+ OSCertHandle cert_handle = CreateOSCertHandleFromBytesWithNickname(data,
+ length,
+ nickname);
+ if (!cert_handle)
+ return NULL;
+
+ X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles());
+ FreeOSCertHandle(cert_handle);
+ return cert;
+}
+
+// static
X509Certificate* X509Certificate::CreateSelfSigned(
crypto::RSAPrivateKey* key,
const std::string& subject,
@@ -922,6 +938,13 @@ bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a,
// static
X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes(
const char* data, int length) {
+ return CreateOSCertHandleFromBytesWithNickname(data, length, NULL);
+}
+
+// static
+X509Certificate::OSCertHandle
+X509Certificate::CreateOSCertHandleFromBytesWithNickname(
+ const char* data, int length, const char* nickname) {
if (length < 0)
return NULL;
@@ -936,8 +959,12 @@ X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes(
der_cert.type = siDERCertBuffer;
// Parse into a certificate structure.
- return CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &der_cert, NULL,
- PR_FALSE, PR_TRUE);
+ X509Certificate::OSCertHandle result =
+ CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &der_cert,
+ const_cast<char*>(nickname),
+ PR_FALSE, PR_TRUE);
+
+ return result;
}
// static

Powered by Google App Engine
This is Rietveld 408576698