你们好,Tengine 团队的成员们, 我在使用最新Tengine2.3.3 版本时遇到了一个问题, 我使用coaps 协议发送 udp 加密请求, tengine会报错,最终导致连接不上。 而我在网上搜索相关 DTLS 解决方案时,http://nginx.org/patches/dtls/README.txt 这个却能访问通。我不知道 Tengine 如何去配置。 我想知道dtls 正确的配置方式。 下面是我的配置示例:
stream {
error_log logs/error.log debug;
upstream emqx_udp {
server 127.0.0.1:5683 max_fails=2 fail_timeout=30s;
zone user_servers 64k;
}
server {
listen 56084 udp ssl;
# enable DTLSv1 or DTLSv1.2 or both protocols
ssl_protocols DTLSv1 DTLSv1.2;
# set up other proxy SSL options as usually
ssl_certificate /usr/local/certs/coapServerCrt.pem;
ssl_certificate_key /usr/local/certs/coapServer.key;
proxy_pass emqx_udp;
}
}
出现如下报错 : 2021/04/02 09:17:48 [debug] 15973#0: 9 SSL handshake handler: 0 2021/04/02 09:17:48 [debug] 15973#0: 9 sendto: fd:10 107 of 107 to "192.168.168.1" 2021/04/02 09:17:48 [debug] 15973#0: 9 SSL_do_handshake: 1 2021/04/02 09:17:48 [debug] 15973#0: 9 event timer del: 10: 43884280 2021/04/02 09:17:48 [debug] 15973#0: 9 SSL: DTLSv1.2, cipher: "ECDHE-ECDSA-AES128-SHA256 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AES(128) Mac=SHA256" 2021/04/02 09:17:48 [debug] 15973#0: 9 event timer del: 10: 43943277 2021/04/02 09:17:48 [debug] 15973#0: 9 generic phase: 2 2021/04/02 09:17:48 [debug] 15973#0: 9 proxy connection handler 2021/04/02 09:17:48 [debug] 15973#0: 9 malloc: 000000000275BA10:432 2021/04/02 09:17:48 [debug] 15973#0: 9 malloc: 000000000273BFB0:16384 2021/04/02 09:17:48 [debug] 15973#0: 9 posix_memalign: 00000000027928F0:256 @16 2021/04/02 09:17:48 [debug] 15973#0: 9 get rr peer, try: 1 2021/04/02 09:17:48 [debug] 15973#0: 9 dgram socket 3 2021/04/02 09:17:48 [debug] 15973#0: 9 epoll add connection: fd:3 ev:80002005 2021/04/02 09:17:48 [debug] 15973#0: 9 connect to 127.0.0.1:5683, fd:3 #10 2021/04/02 09:17:48 [debug] 15973#0: 9 connected 2021/04/02 09:17:48 [debug] 15973#0: 9 proxy connect: 0 2021/04/02 09:17:48 [info] 15973#0: 9 udp proxy 10.0.2.15:57938 connected to 127.0.0.1:5683 2021/04/02 09:17:48 [debug] 15973#0: 9 malloc: 000000000279F980:16384 2021/04/02 09:17:48 [debug] 15973#0: 9 event timer add: 10: 600000:44483459 2021/04/02 09:17:48 [debug] 15973#0: 9 event timer: 10, old: 44483459, new: 44483459 2021/04/02 09:17:48 [debug] 15973#0: recvmsg on 0.0.0.0:56084, ready: 0 2021/04/02 09:17:48 [debug] 15973#0: 9 recvmsg: fd:10 n:253 2021/04/02 09:17:48 [alert] 13058#0: worker process 15973 exited on signal 11 2021/04/02 09:17:48 [debug] 16023#0: epoll add event: fd:10 op:1 ev:00002001 2021/04/02 09:17:49 [debug] 16023#0: recvmsg on 0.0.0.0:56084, ready: 0 2021/04/02 09:17:49 [debug] 16023#0: posix_memalign: 0000000002790990:256 @16 2021/04/02 09:17:49 [debug] 16023#0: posix_memalign: 0000000002792CA0:256 @16 2021/04/02 09:17:49 [debug] 16023#0: malloc: 000000000279EB00:253 2021/04/02 09:17:49 [debug] 16023#0: 11 recvmsg: 192.168.168.1:63704 fd:10 n:253 2021/04/02 09:17:49 [debug] 16023#0: add cleanup: 0000000002790A70 2021/04/02 09:17:49 [debug] 16023#0: posix_memalign: 0000000002790C60:256 @16 2021/04/02 09:17:49 [info] 16023#0: 11 udp client 192.168.168.1:63704 connected to 0.0.0.0:56084 2021/04/02 09:17:49 [debug] 16023#0: 11 posix_memalign: 000000000279F4A0:256 @16 2021/04/02 09:17:49 [debug] 16023#0: 11 generic phase: 0 2021/04/02 09:17:49 [debug] 16023#0: 11 generic phase: 1 2021/04/02 09:17:49 [debug] 16023#0: 11 generic phase: 2 2021/04/02 09:17:49 [debug] 16023#0: 11 posix_memalign: 000000000277A750:256 @16 2021/04/02 09:17:49 [debug] 16023#0: 11 SSL_do_handshake: -1 2021/04/02 09:17:49 [debug] 16023#0: 11 SSL_get_error: 2 2021/04/02 09:17:49 [error] 16023#0: 11 unexcepted message of dtls session while SSL handshaking, udp client: 192.168.168.1, server: 0.0.0.0:56084 2021/04/02 09:17:49 [debug] 16023#0: 11 finalize stream session: 500 2021/04/02 09:17:49 [debug] 16023#0: 11 stream log handler 2021/04/02 09:17:49 [debug] 16023#0: 11 close stream connection: 10 2021/04/02 09:17:49 [debug] 16023#0: 11 reusable connection: 0 2021/04/02 09:17:49 [debug] 16023#0: 11 run cleanup: 0000000002790A70 2021/04/02 09:17:49 [debug] 16023#0: 11 free: 000000000279EB00 2021/04/02 09:17:49 [debug] 16023#0: *11 free: 0000000002790990, unused: 8