我正在编写一个连接到远程服务器并使用自签名证书的程序。我在程序中的几个点出现以下错误。
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);
我对此很陌生,不知道出了什么问题,如果有人可以提出更好的调试方法或找出问题所在,我将不胜感激!
最佳答案
该函数本身并没有做太多工作。唯一可能导致此函数内部而不是 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));
}
关于c - X509_STORE_add_lookup() 中的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18980212/