0

I'm trying to load a certificate using libcrypto. The certificate was generated using keytool and openssl. This is my code

#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;
}

When i run this i'm see this error

139751662126752:error:14FFF0F7:SSL routines:(UNKNOWN)SSL_internal:unknown certificate type:ssl_rsa.c:373:

The certificate and private key are available at https://github.com/apache/qpid-proton/blob/master/python/tests/proton_tests/ssl_db

Any idea why i'm unable to load this cert ? LibreSSL 2.8.0.

Abhijith
  • 2,592
  • 5
  • 18
  • 30
  • It works for me without any changes, using LibreSSL 2.8.0 on macOS. Are you sure you are using what you think you are using? The file ssl_rsa.c does not seem to exist in LibreSSL but it does in OpenSSL. Maybe you have built with the one but are dynamically linking libraries from the other when running? – Reinier Torenbeek Aug 17 '18 at 20:57
  • It also works with OpenSSL 1.0.2g. Maybe you copied the certificate file incorrectly? Double check the file. – SKi Aug 20 '18 at 10:48

0 Answers0