TLS相互认证

时间:2018-09-27 05:29:03

标签: certificate opensl

我使用Amlendra在页面中写的一个很好的例子: https://aticleworld.com/ssl-server-client-using-openssl-in-c/ 一侧身份验证工作正常。

然后,我更改了客户端代码,以在调用SSL_new(ctx)函数后立即在主行中添加以下几行,以加载客户端的证书;

/* set the local certificate from CertFile */
if ( SSL_CTX_use_certificate_file(ctx, CertFile, SSL_FILETYPE_PEM) <= 0 )
{
    ERR_print_errors_fp(stderr);
    abort();
}
/* set the private key from KeyFile (may be the same as CertFile) */
if ( SSL_CTX_use_PrivateKey_file(ctx, KeyFile, SSL_FILETYPE_PEM) <= 0 )
{
    ERR_print_errors_fp(stderr);
    abort();
}
/* verify private key */
if ( !SSL_CTX_check_private_key(ctx) )
{
    fprintf(stderr, "Private key does not match the public certificate\n");
    abort();
}

在服务器端,我调用了以下函数:

SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);

在服务器端,它说没有来自客户端的证书。 有什么建议为什么客户不将证书发送到服务器端?

0 个答案:

没有答案
相关问题