OpenSSL client not sending client certificate

后端 未结 3 1817
孤城傲影
孤城傲影 2021-01-04 22:31

I am struggling with a client certificate problem and hope somebody here can help me. I\'m developing a client/server pair using boost asio but I\'ll try to be unspecific. I

3条回答
  •  囚心锁ツ
    2021-01-04 22:45

    All right, after much suffering, the answer has been found by Dave Thompson of OpenSSL.

    The reason was that my ssl code called all those functions on the OpenSSL context after the socket object (SSL*) was created from it. Which means all those functions did practically nothing or the wrong thing.

    All I had to do was either:

    1. Call SSL_use_certificate_file

    res = SSL_use_certificate_file(ssl, "testclient.crt", SSL_FILETYPE_PEM);
    if (res <= 0) {
        // handle error
    }
    res = SSL_use_PrivateKey_file(ssl, "testclient.key", SSL_FILETYPE_PEM);
    if (res <= 0) {
        // handle error
    }
    

    (notice the missing CTX)

    2. Call the CTX functions

    Call the CTX functions upon the context before the socket was created. As asio seemingly encourages to create the context and socket right afterwards (as I did in the initializer list) the calls were all but useless.

    The SSL context (in lib OpenSSL or asio alike) encapsulates the SSL usage and each socket created from it will share it's properties.

    Thank you guys for your suggestions.

提交回复
热议问题