x509_util_openssl.h revision 116680a4aac90f2aa7413d9095a592090648e557
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 3// found in the LICENSE file. 4 5#ifndef NET_CERT_X509_UTIL_OPENSSL_H_ 6#define NET_CERT_X509_UTIL_OPENSSL_H_ 7 8#include <openssl/asn1.h> 9#include <openssl/x509v3.h> 10 11#include <string> 12#include <vector> 13 14#include "net/base/net_export.h" 15 16namespace base { 17class Time; 18} // namespace base 19 20namespace net { 21 22// A collection of helper functions to fetch data from OpenSSL X509 certificates 23// into more convenient std / base datatypes. 24namespace x509_util { 25 26bool NET_EXPORT ParsePrincipalKeyAndValue(X509_NAME_ENTRY* entry, 27 std::string* key, 28 std::string* value); 29 30bool NET_EXPORT ParsePrincipalKeyAndValueByIndex(X509_NAME* name, 31 int index, 32 std::string* key, 33 std::string* value); 34 35bool NET_EXPORT ParsePrincipalValueByIndex(X509_NAME* name, 36 int index, 37 std::string* value); 38 39bool NET_EXPORT ParsePrincipalValueByNID(X509_NAME* name, 40 int nid, 41 std::string* value); 42 43bool NET_EXPORT ParseDate(ASN1_TIME* x509_time, base::Time* time); 44 45} // namespace x509_util 46 47} // namespace net 48 49#endif // NET_CERT_X509_UTIL_OPENSSL_H_ 50