即使从ca目录中删除了CA,starttls也成功 [英] starttls successful even after deleting CA from the ca dir

查看:69
本文介绍了即使从ca目录中删除了CA,starttls也成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法验证软件的正确行为.这是我为验证操作正确而执行的步骤:

I'm having trouble verifying the correct behavior of my software. Here are the steps I am performing to verify correct operation:

  1. 我有使用openldap库并对ldap服务器执行启动tls的示例代码.
  2. 我第一次为ca cert目录和tlx上下文设置了全局选项.
  3. 之后,我将ldap int和ldap启动tls到服务器.这是成功的,如预期的那样.
  4. 我做了一次ldap_unbind_s
  5. 我从客户端的ca cert目录中删除了签名ldap服务器证书的CA证书.
  6. 再次执行ldap_init和ldap_start_tls_s.
  7. 我希望此调用失败,因为我已删除了ca cert.但是我观察到的是,服务器发送了证书,但是start_tls返回成功.

我正在将openldap 2.4与libssl.0.9.8一起使用

I am using openldap 2.4 with libssl.0.9.8

LDAP *ld;
int desired_version=3;

if ((ld = ldap_init(<hostname>, <server_port>)) == NULL ) {
    printf("ldap_init failed\n");
    exit(0);
}

ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &desired_version);
ldap_set_option(NULL, LDAP_OPT_X_TLS_CTX, NULL);
ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTDIR,"<ca dir>");

if(ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS){
    printf("start tls failed.\n");
    exit(0);
}

...
... <do bind and search>
...

ldap_unbind_s(ld);        
...

// DELETE the CA certificate from the ca dir.    
// Try to do start tls again

if ((ld = ldap_init(hostname, server_port)) == NULL ) {
    printf("ldap_init failed , after deleting CA\n");
    exit(0);
}

// This goes fine even after deleting the CA
if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS){
    printf("start tls failed after deleting CA.\n");
    exit(0);
}

推荐答案

您应重新初始化TLS上下文.

You should reinitialize the TLS Context.

int is_server = 0;ldap_set_option(NULL,LDAP_OPT_X_TLS_NEWCTX,& is_server);

int is_server = 0; ldap_set_option(NULL, LDAP_OPT_X_TLS_NEWCTX, &is_server);

这篇关于即使从ca目录中删除了CA,starttls也成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆