【问题标题】:How to enforce the server to use only TLSv1.2?如何强制服务器仅使用 TLSv1.2?
【发布时间】:2016-01-13 20:49:19
【问题描述】:

我有一个处理soap 请求的服务器。它使用 gSOAP 2.8.14。目前它只允许 TLSv1 连接。我需要强制它只允许 TLSv1.2 连接。

if (soap_ssl_server_context(&soap,
     SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION | SOAP_TLSv1,
     keyfile,      // keyfile: required when server must authenticate to clients
     keyfilepass,  // password to read the key file
     NULL,         // optional cacert file to store trusted certificates
     capath,       // optional capath to directory with trusted certificates
     dhfile,       // DH file name or DH key len bits 
     NULL,         // if randfile!=NULL: use a file with random data
     serverId      // server identification for SSL session cache
     ))
  { 
     printf("SSL Failed to initialize.\n");
     soap_print_fault(&soap, stderr); 
     return;
  }

根据gSOAP changelog,在 gSOAP 2.8.24 中添加了 TLSv1.1 和 TLSv1.2 的标志。所以,我已经将我的 gSOAP 更新到了最新的可用版本 (2.8.27)。如 stdsoap2.h 中的 gSOAP 源中所述,要仅使用 TLSv1.2,我需要使用 SOAP_TLSv1_2 标志:

#define SOAP_TLSv1              0x0000  /* enable TLS v1.0/1.1/1.2 only (default) */
#define SOAP_SSLv3_TLSv1        0x0040  /* enable SSL v3 and TLS v1.0/1.1/1.2 */
#define SOAP_SSLv3              0x0080  /* only SSL v3 */
#define SOAP_TLSv1_0            0x0100  /* only TLS v1.0 */
#define SOAP_TLSv1_1            0x0200  /* only TLS v1.1 */
#define SOAP_TLSv1_2            0x0400  /* only TLS v1.2 */

我已在 soap_ssl_server_context 函数中将 SOAP_TLSv1 替换为 SOAP_TLSv1_2

if (soap_ssl_server_context(&soap,
         SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION | SOAP_TLSv1_2,
         ...))
      { 
         printf("SSL Failed to initialize.\n");
         soap_print_fault(&soap, stderr); 
         return;
      }

但在测试过程中我发现服务器仍然接受通过 TLSv1 的请求。

那么,我的问题是如何强制服务器仅通过 TLSv1.2 处理soap 请求?

【问题讨论】:

  • 可能服务器不支持TLSv1.2。使用 openssl 测试它:openssl s_client -showcerts -tls1_2 -connect [your_host]:[port] 并在此处发布。

标签: gsoap tls1.2


【解决方案1】:

要仅使用 gSOAP 将 TLS 限制为 TLSv1.2,您需要:

  • OpenSSL 1.0.1 或更高版本(否则您可能会默认回到 SSLv3/TLS);
  • 建议升级到 gSOAP 版本 2.8.27 或更高版本。

使用 gsoap 2.8.27 使用选项 SOAP_TLSv1_2 来设置 soap_ssl_client_context()soap_ssl_server_context()。我在http://www.genivia.com/tutorials.html找到了答案

【讨论】:

    猜你喜欢
    • 2019-12-07
    • 2017-09-14
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-12
    • 2019-09-30
    相关资源
    最近更新 更多