summaryrefslogtreecommitdiffstats
path: root/net/base/x509_util_openssl.h
blob: fbe6336e5ead8c7e42ce7bd51e14bb020df56549 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_BASE_X509_UTIL_OPENSSL_H_
#define NET_BASE_X509_UTIL_OPENSSL_H_
#pragma once

#include <openssl/asn1.h>
#include <openssl/x509v3.h>

#include <string>
#include <vector>

#include "net/base/net_export.h"

namespace base {
class Time;
}  // namespace base

namespace net {

// A collection of helper functions to fetch data from OpenSSL X509 certificates
// into more convenient std / base datatypes.
namespace x509_util {

bool NET_EXPORT ParsePrincipalKeyAndValueByIndex(X509_NAME* name,
                                                 int index,
                                                 std::string* key,
                                                 std::string* value);

bool NET_EXPORT ParsePrincipalValueByIndex(X509_NAME* name,
                                           int index,
                                           std::string* value);

bool NET_EXPORT ParsePrincipalValueByNID(X509_NAME* name,
                                         int nid,
                                         std::string* value);

bool NET_EXPORT ParseDate(ASN1_TIME* x509_time, base::Time* time);

} // namespace x509_util

} // namespace net

#endif  // NET_BASE_X509_UTIL_OPENSSL_H_