OpenSSL 1.0.2和错误“SSL_CTX_new:库没有密码”

时间:2016-11-01 17:23:52

标签: c windows openssl

我正在尝试从libest编译并运行一个示例(client-simple)。为此,我在Windows上编译OpenSSL,然后使用它编译和链接libest。

问题在于,当我运行程序时,我得到error:140A90A1:SSL routines:SSL_CTX_new:library has no ciphers

enter image description here

查看调试器中的代码,我可以确认OPENSSL_add_all_algorithms_noconf被调用,以及:

  • ERR_load_crypto_strings()
  • ENGINE_load_builtin_engines();
  • SSL_library_init();
  • SSL_load_error_strings();

可能缺少什么/需要配置以允许OpenSSL找到密码套件?如果我运行与.lib和.dll同时为openSSL构建的openSSL.exe,它会列出许多密码。

导致错误的实际调用是SSL_CTX_new(SSLv23_client_method()))。但是如果我改变客户端方法,它就不会改变。

为什么我遇到错误,我该如何解决?

2 个答案:

答案 0 :(得分:1)

您需要使用TLS 1.1或更高版本。您可能还需要服务器名称指示(SNI)。 SNI入选-servername以下。

我们需要查看更多代码来告诉您问题所在的位置。在此期间,您可能希望访问OpenSSL wiki上的SSL/TLS Client。 (看起来该网站目前正在进行一些维护。这是the Wayback machine的归档版本。)

TLS 1.2

$ openssl s_client -connect testrfc7030.cisco.com:9443 -servername testrfc7030.cisco.com -tls1_2
...
New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: B04740547F80E8F8BFC1B966D28C861F590E7ABB31202E2ED343EFDBA1A08867
    Session-ID-ctx: 
    Master-Key: C6EF3571832C482E1293E78B0410E544140182858A91DDE16FD32CF248D442673C47C902A560A541B1D6C417E35DF804
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1478031623
    Timeout   : 7200 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
    Extended master secret: no

TLS 1.1

$ openssl s_client -connect testrfc7030.cisco.com:9443 -servername testrfc7030.cisco.com -tls1_1
...
New, SSLv3, Cipher is ECDHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.1
    Cipher    : ECDHE-RSA-AES256-SHA
    Session-ID: 62324F8BE5178E801F76B4737DD9F711AC0072E885B8748BB5B8F3ED3D16C8DE
    Session-ID-ctx: 
    Master-Key: 4E44928C5E395E80AEF02533DAA0D237C58B5153CCCA16150B2DEDE361043BFB69D534F52A203084871F1683BDB241EF
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1478031773
    Timeout   : 7200 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
    Extended master secret: no

TLS 1.0

$ openssl s_client -connect testrfc7030.cisco.com:9443 -servername testrfc7030.cisco.com -tls1
CONNECTED(00000003)
write:errno=54
---
no peer certificate available
...
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1
    Cipher    : 0000
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1478031817
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: no

答案 1 :(得分:1)

我的tcp客户端遇到了同样的问题。 所以,我在github中找到了一个代码来尝试运行它来检查我是否得到了相同的错误。

回购链接:SSL TCP-Server

之后我在代码中引入了一行:

waflib.Scripting

这条线解决了我的问题。 你可以在这里找到我的代码: TCP Client-Server with Open SSL