Skip to content

Commit efd800a

Browse files
committed
lib/openssl/MemBio: add BIO_new_mem_buf(std::span)
1 parent 474663d commit efd800a

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/certdb/AcmeClient.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "http/Status.hxx"
1717
#include "lib/fmt/RuntimeError.hxx"
1818
#include "lib/openssl/Buffer.hxx"
19+
#include "lib/openssl/MemBio.hxx"
1920
#include "lib/openssl/UniqueBIO.hxx"
2021
#include "lib/sodium/Base64Alloc.hxx"
2122
#include "util/AllocatedString.hxx"
@@ -399,7 +400,7 @@ AcmeClient::DownloadCertificate(EVP_PKEY &key, const AcmeOrder &order)
399400
GetMimeTypeBase(ct->second) != "application/pem-certificate-chain"sv)
400401
throw std::runtime_error("Wrong Content-Type in certificate download");
401402

402-
UniqueBIO in(BIO_new_mem_buf(response.body.data(), response.body.length()));
403+
const auto in = BIO_new_mem_buf(AsBytes(response.body));
403404
return UniqueX509((X509 *)PEM_ASN1_read_bio((d2i_of_void *)d2i_X509,
404405
PEM_STRING_X509, in.get(),
405406
nullptr, nullptr, nullptr));

src/certdb/Puki.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
#include "lib/openssl/UniqueBIO.hxx"
1919
#include "lib/openssl/UniqueCertKey.hxx"
2020
#include "http/Status.hxx"
21-
#include <span>
2221
#include "util/MimeType.hxx"
22+
#include "util/SpanCast.hxx"
2323
#include "util/StringAPI.hxx"
2424

2525
#include <set>
26+
#include <span>
2627
#include <string>
2728

2829
using std::string_view_literals::operator""sv;
@@ -67,7 +68,7 @@ ObtainPukiCertificate(const PukiConfig &config, X509_REQ &req)
6768
GetMimeTypeBase(ct->second) != "application/x-pem-file"sv)
6869
throw std::runtime_error("Wrong Content-Type in certificate download");
6970

70-
UniqueBIO in{BIO_new_mem_buf(response.body.data(), response.body.length())};
71+
const auto in = BIO_new_mem_buf(AsBytes(response.body));
7172
return UniqueX509{
7273
PEM_read_bio_X509(in.get(), nullptr, nullptr, nullptr)
7374
};

0 commit comments

Comments
 (0)