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 Pem public_key_pem_from_csr(const Pem& signing_request)
17 {
18 X509* icrt = NULL;
19 OpenSSL::Unique_BIO mem(signing_request);
22
23 EVP_PKEY* req_pubkey = X509_REQ_get0_pubkey(csr);
24
25 OpenSSL::CHECK1(PEM_write_bio_PUBKEY(buf, req_pubkey));
26
27 BUF_MEM* bptr;
28 BIO_get_mem_ptr(buf, &bptr);
29 return Pem((uint8_t*)bptr->data, bptr->length);
30 }
31}
Definition pem.h:18
void CHECK1(int rc)
Throws if rc is not 1 and has error.
Definition openssl_wrappers.h:58
Definition base64.h:10
Pem public_key_pem_from_csr(const Pem &signing_request)
Definition csr.h:16
Definition openssl_wrappers.h:161
Definition openssl_wrappers.h:236