X509_STORE_add_lookup()中的分段错误

时间:2013-09-24 11:20:27

标签: c ssl openssl segmentation-fault

我正在编写一个连接到远程服务器并使用自签名证书的程序。我在程序的几个点上得到以下错误。

Program received signal SIGSEGV, Segmentation fault.
0xb7ec3688 in X509_STORE_add_lookup () from /lib/i386-linux-gnu/libcrypto.so.1.0.0

此时:

    if (!SSL_CTX_load_verify_locations(
                ssl_ctx_p, "bundle_test.p12.pem", NULL))

另一个:

Program received signal SIGSEGV, Segmentation fault.
0xb7ec389e in X509_STORE_get_by_subject () from /lib/i386-linux-gnu/libcrypto.so.1.0.0

下面:

ssl_ret = SSL_connect(ssl_p);

我对此很新,不知道出了什么问题,如果有人能提出更好的方法来调试或找出问题,我将不胜感激!

1 个答案:

答案 0 :(得分:1)

该功能本身并没有做太多工作。唯一可以导致此函数内部而不是X509_STORE_load_locations()内部的段错误的是指针解除引用ctx->cert_store。请确认ssl_ctx_p是有效的背景,而不是NULL

int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
                const char *CApath)
        {
        return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath));
        }
相关问题