0

我正在尝试使用 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。

4

0 回答 0