CCF
Loading...
Searching...
No Matches
src
crypto
csr.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the Apache 2.0 License.
3
#pragma once
4
5
#include "
ccf/crypto/openssl/openssl_wrappers.h
"
6
#include "
ccf/crypto/pem.h
"
7
8
#include <openssl/bio.h>
9
10
namespace
ccf::crypto
11
{
16
inline
Pem
public_key_pem_from_csr
(
const
Pem
& signing_request)
17
{
18
OpenSSL::Unique_BIO
mem(signing_request);
19
OpenSSL::Unique_X509_REQ
csr(mem);
20
OpenSSL::Unique_BIO
buf;
21
22
EVP_PKEY* req_pubkey = X509_REQ_get0_pubkey(csr);
23
24
OpenSSL::CHECK1
(PEM_write_bio_PUBKEY(buf, req_pubkey));
25
26
BUF_MEM* bptr =
nullptr
;
27
BIO_get_mem_ptr(buf, &bptr);
28
return
{
reinterpret_cast<
uint8_t*
>
(bptr->data), bptr->length};
29
}
30
}
ccf::crypto::Pem
Definition
pem.h:18
ccf::crypto::OpenSSL::CHECK1
void CHECK1(int rc)
Throws if rc is not 1 and has error.
Definition
openssl_wrappers.h:54
ccf::crypto
Definition
base64.h:10
ccf::crypto::public_key_pem_from_csr
Pem public_key_pem_from_csr(const Pem &signing_request)
Definition
csr.h:16
openssl_wrappers.h
pem.h
ccf::crypto::OpenSSL::Unique_BIO
Definition
openssl_wrappers.h:159
ccf::crypto::OpenSSL::Unique_X509_REQ
Definition
openssl_wrappers.h:233
Generated by
1.9.8