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

Side by Side Diff: net/base/x509_openssl_util.h

Issue 4184004: Add support for certificate name checking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wtc comments, plus moved method to x509_openssl_util Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef NET_BASE_X509_OPENSSL_UTIL_H_ 5 #ifndef NET_BASE_X509_OPENSSL_UTIL_H_
6 #define NET_BASE_X509_OPENSSL_UTIL_H_ 6 #define NET_BASE_X509_OPENSSL_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <openssl/asn1.h> 9 #include <openssl/asn1.h>
10 #include <openssl/x509v3.h> 10 #include <openssl/x509v3.h>
11 11
12 #include <string> 12 #include <string>
13 #include <vector>
13 14
14 namespace base { 15 namespace base {
15 class Time; 16 class Time;
16 } // namespace base 17 } // namespace base
17 18
18 namespace net { 19 namespace net {
19 20
20 // A collection of helper functions to fetch data from OpenSSL X509 certificates 21 // A collection of helper functions to fetch data from OpenSSL X509 certificates
21 // into more convenient std / base datatypes. 22 // into more convenient std / base datatypes.
22 namespace x509_openssl_util { 23 namespace x509_openssl_util {
23 24
24 bool ParsePrincipalKeyAndValueByIndex(X509_NAME* name, 25 bool ParsePrincipalKeyAndValueByIndex(X509_NAME* name,
25 int index, 26 int index,
26 std::string* key, 27 std::string* key,
27 std::string* value); 28 std::string* value);
28 29
29 bool ParsePrincipalValueByIndex(X509_NAME* name, int index, std::string* value); 30 bool ParsePrincipalValueByIndex(X509_NAME* name, int index, std::string* value);
30 31
31 bool ParsePrincipalValueByNID(X509_NAME* name, int nid, std::string* value); 32 bool ParsePrincipalValueByNID(X509_NAME* name, int nid, std::string* value);
32 33
33 bool ParseDate(ASN1_TIME* x509_time, base::Time* time); 34 bool ParseDate(ASN1_TIME* x509_time, base::Time* time);
34 35
36 // Verifies that |hostname| matches one of the names in |cert_names|, based on
37 // TLS name matching rules. The members of |cert_names| must have been
wtc 2010/11/03 00:29:49 Nit: cite the RFC or Internet-Draft that specifies
joth 2010/11/12 18:55:23 Done.
38 // extracted from the Subject CN or SAN fields of a certificate. See also
39 // GetDNSNames.
40 // TODO(joth): Investigate if we can upstream this into the OpenSSL library,
41 // to avoid duplicating this logic across projects.
42 bool VerifyHostname(const std::string& hostname,
43 const std::vector<std::string>& cert_names);
44
35 } // namespace x509_openssl_util 45 } // namespace x509_openssl_util
36 46
37 } // namespace net 47 } // namespace net
38 48
39 #endif // NET_BASE_X509_OPENSSL_UTIL_H_ 49 #endif // NET_BASE_X509_OPENSSL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698