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

Side by Side Diff: net/cert/x509_certificate_nss.cc

Issue 634033002: Check whether or not a certificate is self-signed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cert/x509_certificate.h" 5 #include "net/cert/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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 cert_handle->derCert.len); 259 cert_handle->derCert.len);
260 } 260 }
261 261
262 // static 262 // static
263 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, 263 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
264 size_t* size_bits, 264 size_t* size_bits,
265 PublicKeyType* type) { 265 PublicKeyType* type) {
266 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); 266 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type);
267 } 267 }
268 268
269 // static
270 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) {
271 SECKEYPublicKey* public_key = CERT_ExtractPublicKey(cert_handle);
272 if (!public_key)
273 return false;
274
275 SECStatus verified = CERT_VerifySignedDataWithPublicKey(
276 &cert_handle->signatureWrap, public_key, NULL);
277 return verified == SECSuccess;
278 }
279
269 } // namespace net 280 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698