我正在尝试使用libcrypto加载证书。该证书是使用keytool和openssl生成的。 这是我的代码
#include <stdio.h>
#include <openssl/ssl.h>
int main(int argc, char **argv)
{
SSL* ssl;
SSL_CTX* ctx;
SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
ctx = SSL_CTX_new(SSLv23_server_method());
char filename[256];
// https://github.com/apache/qpid-proton/blob/master/python/tests/proton_tests/ssl_db/server-certificate.pem
sprintf(filename, "%s", "server-certificate.pem");
char keyfile[256];
https://github.com/apache/qpid-proton/blob/master/python/tests/proton_tests/ssl_db/server-private-key.pem
sprintf(keyfile, "%s", "server-private-key.pem'");
int retval = SSL_CTX_use_certificate_chain_file(ctx, filename);
unsigned long err = ERR_peek_last_error();
printf("return value = %d\n", retval);
ERR_print_errors_fp(stdout);
return 0;
}
运行此命令时,我会看到此错误
139751662126752:error:14FFF0F7:SSL routines:(UNKNOWN)SSL_internal:unknown certificate type:ssl_rsa.c:373:
证书和私钥位于https://github.com/apache/qpid-proton/blob/master/python/tests/proton_tests/ssl_db
有人知道为什么我无法加载此证书吗? LibreSSL 2.8.0。