-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hello, I want to write a key pair EvpPKey to an IOBuffer in PEM format. How can I do that?
I assumed this would work:
using OpenSSL
rsa_key = OpenSSL.EvpPKey(rsa_generate_key())
io = IOBuffer()
write(io, rsa_key)but it throws an error
OpenSSL.OpenSSLError("404824FD01000000:error:04880007:PEM routines:PEM_write_bio:BUF lib:crypto/pem/pem_lib.c:664:\n")
For the public key I wrote this function
function write_pubkey(io::IO, evp_pkey::OpenSSL.EvpPKey)
bio = OpenSSL.BIO(io)
GC.@preserve bio io begin
# int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x);
if ccall(
(:PEM_write_bio_PUBKEY, libcrypto),
Cint,
(OpenSSL.BIO, OpenSSL.EvpPKey),
bio,
evp_pkey) != 1
throw(OpenSSL.OpenSSLError())
end
end
endusing OpenSSL
rsa_key = OpenSSL.EvpPKey(rsa_generate_key())
io = IOBuffer()
write_pubkey(io, rsa_key)and get the same error
OpenSSL.OpenSSLError("404824FD01000000:error:04880007:PEM routines:PEM_write_bio:BUF lib:crypto/pem/pem_lib.c:664:\n")
Is there something I'm missing when it comes to configuring the IOBuffer and the OpenSSL.BIO?
Metadata
Metadata
Assignees
Labels
No labels