workflow icon indicating copy to clipboard operation
workflow copied to clipboard

Windows下 https异常

Open shenxuebing opened this issue 2 years ago • 6 comments

#include <stdio.h>
#include "workflow/WFHttpServer.h"

int main()
{
	WFHttpServer server([](WFHttpTask* task) {
		task->get_resp()->append_output_body("<html>Hello World!</html>");
		});

	if (server.start(8888,"server.crt", "server.key") == 0) { // start server on port 8888
		getchar(); // press "Enter" to end.
		server.stop();
	}

	return 0;
}

测试工具postman,openssl 版本为1.1.1c,server.key和server.crt来源于test/http_unittest.cc。 postman全局配置已关闭ssl认证。 image

  1. 情景1:

windows下使用v0.9.11,编译上述代码,使用postman测试,

  • 问题1:需要勾选当前请求的ssl版本才能正常请求,且有响应值。 image

  • 问题2:(1)第二次发送请求,去除http headers ,无法正常响应,postman报 error:socket hang up;(2)重新新建一个请求可以正常响应。(3)重启http服务后,首次使用无http headers的请求,可以正常响应。 image

  1. 情景2: Linux下使用v0.10.1 编译上述同样的代码,请求过程一样,无需设置ssl协议版本,都能够正常请求与响应。没有复现windows下的问题。

shenxuebing avatar Jun 12 '22 09:06 shenxuebing

你好,能不能帮我们跟一下这个问题😂 Windows版的Communicator处理SSL的逻辑,我也有点看不懂。之前也有人报过windows下https server的问题,查了很久没查出来,有些环境下又没问题,怀疑和SSL版本有关。

Barenboim avatar Jun 12 '22 10:06 Barenboim

+1 用UE4 http模块获取数据。http 没问题, https 就报错 说没有验证 crt。 可是 用 https 获取 google 图片又是可以的,很奇怪。

tiantianaixuexi avatar Jun 15 '22 07:06 tiantianaixuexi

+1 用UE4 http模块获取数据。http 没问题, https 就报错 说没有验证 crt。 可是 用 https 获取 google 图片又是可以的,很奇怪。

应该是我们的Windows版SSL server有点问题。我们这边再查一下。 Unix版的核心代码是精心构建的,可以保证完全的严密。Windows版的,还是差一些...

Barenboim avatar Jun 15 '22 07:06 Barenboim

调试了一下程序,实在没看出来哪个地方出的问题,这个SSL写的我也没看懂。。。。和成功的请求对比了一下,失败的请求在get_io_result接口时,在获取iocp_data后,if (iocp_data->deadline > 0)// timeout > 0,会进入超时。如果有需要可以提供远程排查问题。

shenxuebing avatar Jun 21 '22 15:06 shenxuebing

麻烦@dengjunplusplus 有空的话跟一下。

Barenboim avatar Jun 21 '22 17:06 Barenboim

麻烦@dengjunplusplus 有空的话跟一下。

我这边可以复现,正在排查中 @Barenboim

dengjun101 avatar Jun 22 '22 07:06 dengjun101

https://github.com/sogou/workflow/pull/1031 @xuebing1995 Windows下可以用这个应急一下。使用WFHttpsServer,多了个's',启动和关闭方法是一样的。 原理上,绕开了kernel里的SSL层,使用普通的socket和我们的SSLWrapper作协议叠加,这个方法会比之前的快,因为SSLWrapper的实现比kernel_win里的好很多。

Barenboim avatar Aug 29 '22 12:08 Barenboim

收到,已用最新代码测试,尚未发现问题。

shenxuebing avatar Aug 30 '22 04:08 shenxuebing

我先关闭了这个issue哈。有发现新问题重新打开。

Barenboim avatar Sep 01 '22 07:09 Barenboim