https for embedded use case (certificates) #228
Answered
by
babelouest
nicolasb565
asked this question in
Q&A
-
Hi, I am wondering how you generate the certificate and private key for ulfius_start_secure_framework(). I tried a few examples from libmicrohttpd documentation but I did not manage to make it work. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
babelouest
May 17, 2022
Replies: 1 comment
-
Hello, For tests purpose, you can generate a self-signed certificate using openssl (see example) or GnuTLS' certtool: $ # example with openssl
$ openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout localhost.key -out localhost.crt -subj "/CN=localhost"
$
$ # example with certtool
$ certtool --generate-privkey --outfile localhost.key --sec-param High
$ certtool --generate-self-signed --load-privkey localhost.key --outfile localhost.crt Then, you can use the content of the files const char key_pem[] =
"-----BEGIN RSA PRIVATE KEY-----\
MIIG4wIBAA[...]LolR+U2f7QAiM1K+x\
-----END RSA PRIVATE KEY-----";
const char cert_pem[] =
"-----BEGIN CERTIFICATE-----
MIIEJDCCAoygAw[...]AAJx6S6cOEEM1\
+L6JIqXTCzQ=
-----END CERTIFICATE-----";
ulfius_start_secure_framework(&instance, key_pem, cert_pem); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
babelouest
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
For tests purpose, you can generate a self-signed certificate using openssl (see example) or GnuTLS' certtool:
Then, you can use the content of the files
localhost.key
andlocalhost.crt
as parameterskey_pem
andcert_pem
in the functionulfius_start_secure_framework
: