Home | History | Annotate | Download | only in base
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef NET_BASE_X509_OPENSSL_UTIL_H_
      6 #define NET_BASE_X509_OPENSSL_UTIL_H_
      7 #pragma once
      8 
      9 #include <openssl/asn1.h>
     10 #include <openssl/x509v3.h>
     11 
     12 #include <string>
     13 #include <vector>
     14 
     15 namespace base {
     16 class Time;
     17 }  // namespace base
     18 
     19 namespace net {
     20 
     21 // A collection of helper functions to fetch data from OpenSSL X509 certificates
     22 // into more convenient std / base datatypes.
     23 namespace x509_openssl_util {
     24 
     25 bool ParsePrincipalKeyAndValueByIndex(X509_NAME* name,
     26                                       int index,
     27                                       std::string* key,
     28                                       std::string* value);
     29 
     30 bool ParsePrincipalValueByIndex(X509_NAME* name, int index, std::string* value);
     31 
     32 bool ParsePrincipalValueByNID(X509_NAME* name, int nid, std::string* value);
     33 
     34 bool ParseDate(ASN1_TIME* x509_time, base::Time* time);
     35 
     36 } // namespace x509_openssl_util
     37 
     38 } // namespace net
     39 
     40 #endif  // NET_BASE_X509_OPENSSL_UTIL_H_
     41