Skip to content

SSL context is not getting set in cpp code #1802

Open
@vijaygouda

Description

@vijaygouda

I am setting ssl context in cpp code which uses cpprestsdk lib to host endpoint server, using boost and openssl also

config.set_ssl_context_callback([](boost::asio::ssl::context& ctx) {
            ctx.set_options(boost::asio::ssl::context::default_workarounds | 
                    boost::asio::ssl::context::no_sslv2 |
                    boost::asio::ssl::context::no_sslv3 |
                    boost::asio::ssl::context::tlsv13);

            std::string cert_chain_file = "path/cert.pem";
            std::string private_key_file = "path/privatekey.pem";
            std::string ca_cert_file = "path/rootcertificate.pem";
                        ctx.use_certificate_chain_file(cert_chain_file);
    ctx.use_private_key_file(private_key_file, boost::asio::ssl::context::pem);
    ctx.load_verify_file(ca_cert_file);

    ctx.set_verify_mode(boost::asio::ssl::verify_peer | boost::asio::ssl::verify_fail_if_no_peer_cert);
        });

This is how i m setting context to http_listener_config config
I m able to host the server, but when client try to access the server i m getting segmentation fault, code is crashing at

#1  0x00007ffff791515c in CRYPTO_strdup () from /home/serviceTemplateFile/code/Project/CEALhttpsTest/LocalExternalFiles/openssl/lib/libcrypto.so.3
#2  0x00007ffff7a8a604 in x509_pubkey_ex_new_ex () from /home/serviceTemplateFile/code/Project/CEALhttpsTest/LocalExternalFiles/openssl/lib/libcrypto.so.3
#3  0x00007ffff77c861d in asn1_template_new () from /home/serviceTemplateFile/code/Project/CEALhttpsTest/LocalExternalFiles/openssl/lib/libcrypto.so.3
#4  0x00007ffff77c85e5 in asn1_template_new () from /home/serviceTemplateFile/code/Project/CEALhttpsTest/LocalExternalFiles/openssl/lib/libcrypto.so.3
#5  0x00007ffff77c8b03 in ASN1_item_new_ex () from /home/serviceTemplateFile/code/Project/CEALhttpsTest/LocalExternalFiles/openssl/lib/libcrypto.so.3
#6  0x00007ffff7a8cf12 in X509_new_ex () from /home/serviceTemplateFile/code/Project/CEALhttpsTest/LocalExternalFiles/openssl/lib/libcrypto.so.3
#7  0x00007ffff6bf86aa in SSL_CTX_use_certificate_chain_file ()

This is the gdb crash , it says its crashing at setting chain file

One thing is , this is happenning only for openssl 3.1 version and not for openssl 1.1.1
If i m building my same code with ssl 1.1.1 , no error and its working perfectly fine, crash happens only for code built with ssl 3.1 version,
What and how should i set in ssl 3.1 version is there any change in the way setting it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions