【发布时间】:2018-03-16 22:07:45
【问题描述】:
有一个使用 openssl 的简单服务器和客户端。应用程序是 C++ 并使用我自己构建的 openssl-1.1.0g 源代码。我提供客户端和服务器证书以及私钥的简单案例工作正常。握手很好,数据传输也很好。现在我还有两个要求:
-
需要在服务器上禁用客户端身份验证。客户端将拥有 CA 证书,但没有私钥。客户端将进行服务器身份验证。
不知道如何告诉openssl api不要请求客户端证书
[更新]已修复。在 conf 文件中,在客户端部分尝试使用关键字 VerifyCAFile 获取 CA 证书并删除 PrivateKey。无需任何代码更改即可成功握手。
-
禁用客户端和服务器身份验证。双方都没有证书或私钥。
尝试使用未指定证书或密钥的 conf 文件中的 anon 部分。还要在 conf 文件的这一部分中设置密码字符串为空。 aNULL 是此处页面中所有匿名密码的列表:
https://www.openssl.org/docs/man1.1.0/apps/ciphers.html
但这不起作用。
这是设置-
服务器:
SSL_CTX_new(TLS_server_method()) - create server ctx
CONF_modules_load_file - load conf file
SSL_CTX_config - get section for server
BIO_new_socket((int)socket, BIO_CLOSE) - create socket BIO
SSL_new(ctx) - create ssl
SSL_set_bio - set bio in ssl
SSL_set_accept_state(_ssl); - set accept for server
SSL_do_handshake - do handshake
客户:
SSL_CTX_new(TLS_client_method()) - create server ctx
CONF_modules_load_file - load conf file
SSL_CTX_config - get section for client
BIO_new_socket((int)socket, BIO_CLOSE) - create socket BIO
SSL_new(ctx) - create ssl
SSL_set_bio - set bio in ssl
SSL_set_connect_state(ssl) - set connect for client
SSL_do_handshake - do handshake
配置文件:
testApp = test_sect
[test_sect]
# list of configuration modules
ssl_conf = ssl_sect
[ssl_sect]
server = server_section
client = client_section
anon = anon_section
[server_section]
CipherString = DEFAULT
Certificate = <path to server.cer>
PrivateKey = <path to server.key>
[client_section]
CipherString = DEFAULT
Certificate = <path to client.cer>
PrivateKey = <path to client.key>
[anon_section]
CipherString = aNULL
【问题讨论】:
-
检查this