CCF
Loading...
Searching...
No Matches
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
6#include "ccf/crypto/pem.h"
7
8#include <openssl/bio.h>
9
10namespace ccf::crypto
11{
16 inline Pem public_key_pem_from_csr(const Pem& signing_request)
17 {
18 OpenSSL::Unique_BIO mem(signing_request);
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}
Definition pem.h:18
void CHECK1(int rc)
Throws if rc is not 1 and has error.
Definition openssl_wrappers.h:54
Definition base64.h:10
Pem public_key_pem_from_csr(const Pem &signing_request)
Definition csr.h:16
Definition openssl_wrappers.h:159
Definition openssl_wrappers.h:233