[GH-ISSUE #3484] tls_enable = true xtcp wsarecv: An existing connection was forcibly closed by the remote host. #2785

Closed
opened 2026-05-05 13:47:51 -06:00 by gitea-mirror · 10 comments
Owner

Originally created by @Gu-f on GitHub (Jun 10, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3484

Bug Description

当我开启了tls后,无法连接。删除client配置文件中的tls_enable = true和server配置文件中的tls_only = true后正常连接。
看了文档后我又生成了证书添加了证书配置,还是依然无法连接。
证书使用的是 DigiCert 免费版 SSL 证书。
证书下载下来后有三个文件,分别是:
mydomain.key
mydomain_chain.crt (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书)
mydomain_public.crt

frpc Version

0.49.0

frps Version

0.49.0

System Architecture

frpc:win10 x64 , frps: linux/x86_64

Configurations

未指定证书的情况:
client:

[common]
tls_enable = true
server_addr = mydomain
server_port = 26000
token = mytoken

[11111111]
type = xtcp
sk = 11111111
local_ip = 127.0.0.1
local_port = 2556

server:

[common]
bind_port = 26000
bind_udp_port = 26001
token = mytoken
log_file = /opt/frplog/frp.log
log_level = info
log_max_days = 30
dashboard_port = 25001
dashboard_user = myuser
dashboard_pwd = mypwd
tls_only = true

指定证书的情况:
client:

[common]
tls_enable = true
tls_trusted_ca_file = ./mydoamin_chain.crt
server_addr = mydomain
server_port = 26000
token = mytoken

[11111111]
type = xtcp
sk = 11111111
local_ip = 127.0.0.1
local_port = 2556

server:

[common]
bind_port = 26000
bind_udp_port = 26001
token = mytoken
log_file = /opt/frplog/frp.log
log_level = info
log_max_days = 30
dashboard_port = 25001
dashboard_user = myuser
dashboard_pwd = mypwd
tls_only = true
tls_cert_file = ./mydomain_public.crt
tls_key_file = ./mydomain.key

Logs

不管是否指定证书报错一样,如下。

2023/06/10 23:31:30 [W] [service.go:131] login to server failed: read tcp 192.168.124.17:7425->mydomain_ip:26000: wsarecv: An existing connection was forcibly closed by the remote host.
read tcp 192.168.124.17:7425->mydomain_ip:26000: wsarecv: An existing connection was forcibly closed by the remote host.

Steps to reproduce

  1. 写入上述表述的配置
  2. 启动frp

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @Gu-f on GitHub (Jun 10, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3484 ### Bug Description 当我开启了tls后,无法连接。删除client配置文件中的`tls_enable = true`和server配置文件中的`tls_only = true`后正常连接。 看了文档后我又生成了证书添加了证书配置,还是依然无法连接。 证书使用的是 DigiCert 免费版 SSL 证书。 证书下载下来后有三个文件,分别是: mydomain.key mydomain_chain.crt (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书) mydomain_public.crt ### frpc Version 0.49.0 ### frps Version 0.49.0 ### System Architecture frpc:win10 x64 , frps: linux/x86_64 ### Configurations 未指定证书的情况: client: ``` [common] tls_enable = true server_addr = mydomain server_port = 26000 token = mytoken [11111111] type = xtcp sk = 11111111 local_ip = 127.0.0.1 local_port = 2556 ``` server: ``` [common] bind_port = 26000 bind_udp_port = 26001 token = mytoken log_file = /opt/frplog/frp.log log_level = info log_max_days = 30 dashboard_port = 25001 dashboard_user = myuser dashboard_pwd = mypwd tls_only = true ``` 指定证书的情况: client: ``` [common] tls_enable = true tls_trusted_ca_file = ./mydoamin_chain.crt server_addr = mydomain server_port = 26000 token = mytoken [11111111] type = xtcp sk = 11111111 local_ip = 127.0.0.1 local_port = 2556 ``` server: ``` [common] bind_port = 26000 bind_udp_port = 26001 token = mytoken log_file = /opt/frplog/frp.log log_level = info log_max_days = 30 dashboard_port = 25001 dashboard_user = myuser dashboard_pwd = mypwd tls_only = true tls_cert_file = ./mydomain_public.crt tls_key_file = ./mydomain.key ``` ### Logs 不管是否指定证书报错一样,如下。 ``` 2023/06/10 23:31:30 [W] [service.go:131] login to server failed: read tcp 192.168.124.17:7425->mydomain_ip:26000: wsarecv: An existing connection was forcibly closed by the remote host. read tcp 192.168.124.17:7425->mydomain_ip:26000: wsarecv: An existing connection was forcibly closed by the remote host. ``` ### Steps to reproduce 1. 写入上述表述的配置 2. 启动frp ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [X] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:47:51 -06:00
Author
Owner

@limaofu commented on GitHub (Jun 12, 2023):

你可以参考cof-lee的方档: https://limaofu.github.io/
代理服务器操作手册-0607-back.docx

<!-- gh-comment-id:1587330096 --> @limaofu commented on GitHub (Jun 12, 2023): 你可以参考cof-lee的方档: https://limaofu.github.io/ [代理服务器操作手册-0607-back.docx](https://limaofu.github.io/t3doc/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C-0607-back.docx)
Author
Owner

@Gu-f commented on GitHub (Jun 13, 2023):

你可以参考cof-lee的方档: https://limaofu.github.io/ 代理服务器操作手册-0607-back.docx

感谢回答,出现这个问题我猜测大概率是证书的问题。通过文对比,有些疑问cof-lee的文档中的样例是否是一个双向验证的样例,是否等价于文档自定义TLS协议加密|frp 这部分提到的内容?。
我的疑问点在于,如果我使用的不是自签名证书,例如使用Let's Encrypt或者是DigiCert 生成的证书,我应该下载的是什么格式的证书,并且与frpc.ini和frps.ini中的配置项tls_cert_file = frpc-1.xxxx.com.crt、tls_key_file = frpc-1.xxxx.com.key、tls_trusted_ca_file = frpca.crt如何对应,我感觉我在指定证书配置的时候没有指定正确,目前我对tls证书这块了解不深入,可以举个示例吗。
比如说,我在DigiCert申请后,证书下载Apache类型后有三个文件,分别是:
mydomain.key
mydomain_chain.crt (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书)
mydomain_public.crt
那么在frp配置中我应该如何指定tls_cert_file、tls_key_file、tls_trusted_ca_file这三个配置项呢?
或者说我需要下载其他类型的格式?
感谢帮助!

<!-- gh-comment-id:1588413687 --> @Gu-f commented on GitHub (Jun 13, 2023): > 你可以参考cof-lee的方档: https://limaofu.github.io/ [代理服务器操作手册-0607-back.docx](https://limaofu.github.io/t3doc/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C-0607-back.docx) 感谢回答,出现这个问题我猜测大概率是证书的问题。通过文对比,有些疑问cof-lee的文档中的样例是否是一个双向验证的样例,是否等价于文档[自定义TLS协议加密|frp](https://gofrp.org/docs/features/common/network/network-tls/#%E5%8F%8C%E5%90%91%E9%AA%8C%E8%AF%81) 这部分提到的内容?。 我的疑问点在于,如果我使用的不是自签名证书,例如使用Let's Encrypt或者是DigiCert 生成的证书,我应该下载的是什么格式的证书,并且与frpc.ini和frps.ini中的配置项`tls_cert_file = frpc-1.xxxx.com.crt、tls_key_file = frpc-1.xxxx.com.key、tls_trusted_ca_file = frpca.crt`如何对应,我感觉我在指定证书配置的时候没有指定正确,目前我对tls证书这块了解不深入,可以举个示例吗。 比如说,我在DigiCert申请后,证书下载Apache类型后有三个文件,分别是: mydomain.key mydomain_chain.crt (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书) mydomain_public.crt 那么在frp配置中我应该如何指定`tls_cert_file、tls_key_file、tls_trusted_ca_file`这三个配置项呢? 或者说我需要下载其他类型的格式? 感谢帮助!
Author
Owner

@fatedier commented on GitHub (Jun 13, 2023):

一般来说,非自签名的证书不需要配置 tls_trusted_ca_file

启用 tls_enable 不配置证书的话,默认证书是自动生成的,如果这个连接不上,配置证书原理也是一样的。

可有考虑 frpc 增加 disable_custom_tls_first_byte = true 配置试试看,或者 protocol 使用 quic 也可以试一试。

<!-- gh-comment-id:1588468055 --> @fatedier commented on GitHub (Jun 13, 2023): 一般来说,非自签名的证书不需要配置 `tls_trusted_ca_file` 。 启用 `tls_enable` 不配置证书的话,默认证书是自动生成的,如果这个连接不上,配置证书原理也是一样的。 可有考虑 frpc 增加 `disable_custom_tls_first_byte = true` 配置试试看,或者 protocol 使用 quic 也可以试一试。
Author
Owner

@Gu-f commented on GitHub (Jun 13, 2023):

一般来说,非自签名的证书不需要配置 tls_trusted_ca_file

启用 tls_enable 不配置证书的话,默认证书是自动生成的,如果这个连接不上,配置证书原理也是一样的。

可有考虑 frpc 增加 disable_custom_tls_first_byte = true 配置试试看,或者 protocol 使用 quic 也可以试一试。

好的,我增加disable_custom_tls_first_byte = true试试。
只启用tls_enable不配置证书的话试过了,是连接不上的,我印象在文档某个位置看到一条信息说是从某个版本后,启用tls_enable后必须要配置证书了,不确定该信息是否还有效。

<!-- gh-comment-id:1588473437 --> @Gu-f commented on GitHub (Jun 13, 2023): > 一般来说,非自签名的证书不需要配置 `tls_trusted_ca_file` 。 > > 启用 `tls_enable` 不配置证书的话,默认证书是自动生成的,如果这个连接不上,配置证书原理也是一样的。 > > 可有考虑 frpc 增加 `disable_custom_tls_first_byte = true` 配置试试看,或者 protocol 使用 quic 也可以试一试。 好的,我增加`disable_custom_tls_first_byte = true`试试。 只启用tls_enable不配置证书的话试过了,是连接不上的,我印象在文档某个位置看到一条信息说是从某个版本后,启用tls_enable后必须要配置证书了,不确定该信息是否还有效。
Author
Owner

@fatedier commented on GitHub (Jun 13, 2023):

你可以找一下是哪个文档

<!-- gh-comment-id:1588498269 --> @fatedier commented on GitHub (Jun 13, 2023): 你可以找一下是哪个文档
Author
Owner

@Gu-f commented on GitHub (Jun 13, 2023):

试验结果如下:
增加disable_custom_tls_first_byte = true无效,依然是同样的问题。
protocol使用quic工作正常了,但是带来了一个新问题。使用quic后无论是否添加tls_enable、无论指定的证书是否正确(证书格式正确不是同一私钥签发的两张证书),都能成功与server建立连接。这是什么原因

<!-- gh-comment-id:1588549102 --> @Gu-f commented on GitHub (Jun 13, 2023): 试验结果如下: 增加`disable_custom_tls_first_byte = true`无效,依然是同样的问题。 protocol使用quic工作正常了,但是带来了一个新问题。使用quic后无论是否添加tls_enable、无论指定的证书是否正确(证书格式正确不是同一私钥签发的两张证书),都能成功与server建立连接。这是什么原因
Author
Owner

@cxiaolng commented on GitHub (Jun 21, 2023):

frp_0.48.0 版本

tls_enable = true 不论是否开启,都一直报wsarecv: An existing connection was forcibly closed by the remote host.

frpc.ini增加disable_custom_tls_first_byte = true 有效

<!-- gh-comment-id:1600013687 --> @cxiaolng commented on GitHub (Jun 21, 2023): frp_0.48.0 版本 tls_enable = true 不论是否开启,都一直报wsarecv: An existing connection was forcibly closed by the remote host. frpc.ini增加disable_custom_tls_first_byte = true 有效
Author
Owner

@github-actions[bot] commented on GitHub (Jul 22, 2023):

Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:1646357866 --> @github-actions[bot] commented on GitHub (Jul 22, 2023): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Author
Owner

@ac-sc commented on GitHub (Aug 10, 2023):

你可以参考cof-lee的方档: https://limaofu.github.io/ 代理服务器操作手册-0607-back.docx

感谢回答,出现这个问题我猜测大概率是证书的问题。通过文对比,有些疑问cof-lee的文档中的样例是否是一个双向验证的样例,是否等价于文档自定义TLS协议加密|frp 这部分提到的内容?。 我的疑问点在于,如果我使用的不是自签名证书,例如使用Let's Encrypt或者是DigiCert 生成的证书,我应该下载的是什么格式的证书,并且与frpc.ini和frps.ini中的配置项tls_cert_file = frpc-1.xxxx.com.crt、tls_key_file = frpc-1.xxxx.com.key、tls_trusted_ca_file = frpca.crt如何对应,我感觉我在指定证书配置的时候没有指定正确,目前我对tls证书这块了解不深入,可以举个示例吗。 比如说,我在DigiCert申请后,证书下载Apache类型后有三个文件,分别是: mydomain.key mydomain_chain.crt (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书) mydomain_public.crt 那么在frp配置中我应该如何指定tls_cert_file、tls_key_file、tls_trusted_ca_file这三个配置项呢? 或者说我需要下载其他类型的格式? 感谢帮助!

这个证书的问题,最终是怎样填的呢,看了下还是没理解到!

<!-- gh-comment-id:1672541818 --> @ac-sc commented on GitHub (Aug 10, 2023): > > 你可以参考cof-lee的方档: https://limaofu.github.io/ [代理服务器操作手册-0607-back.docx](https://limaofu.github.io/t3doc/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C-0607-back.docx) > > 感谢回答,出现这个问题我猜测大概率是证书的问题。通过文对比,有些疑问cof-lee的文档中的样例是否是一个双向验证的样例,是否等价于文档[自定义TLS协议加密|frp](https://gofrp.org/docs/features/common/network/network-tls/#%E5%8F%8C%E5%90%91%E9%AA%8C%E8%AF%81) 这部分提到的内容?。 我的疑问点在于,如果我使用的不是自签名证书,例如使用Let's Encrypt或者是DigiCert 生成的证书,我应该下载的是什么格式的证书,并且与frpc.ini和frps.ini中的配置项`tls_cert_file = frpc-1.xxxx.com.crt、tls_key_file = frpc-1.xxxx.com.key、tls_trusted_ca_file = frpca.crt`如何对应,我感觉我在指定证书配置的时候没有指定正确,目前我对tls证书这块了解不深入,可以举个示例吗。 比如说,我在DigiCert申请后,证书下载Apache类型后有三个文件,分别是: mydomain.key mydomain_chain.crt (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书) mydomain_public.crt 那么在frp配置中我应该如何指定`tls_cert_file、tls_key_file、tls_trusted_ca_file`这三个配置项呢? 或者说我需要下载其他类型的格式? 感谢帮助! 这个证书的问题,最终是怎样填的呢,看了下还是没理解到!
Author
Owner

@limaofu commented on GitHub (Aug 16, 2023):

加我v信, Cof-Lee

On Thu, Aug 10, 2023, 12:38 aocheng @.***> wrote:

你可以参考cof-lee的方档: https://limaofu.github.io/ 代理服务器操作手册-0607-back.docx
https://limaofu.github.io/t3doc/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C-0607-back.docx

感谢回答,出现这个问题我猜测大概率是证书的问题。通过文对比,有些疑问cof-lee的文档中的样例是否是一个双向验证的样例,是否等价于文档
自定义TLS协议加密|frp
https://gofrp.org/docs/features/common/network/network-tls/#%E5%8F%8C%E5%90%91%E9%AA%8C%E8%AF%81
这部分提到的内容?。 我的疑问点在于,如果我使用的不是自签名证书,例如使用Let's Encrypt或者是DigiCert
生成的证书,我应该下载的是什么格式的证书,并且与frpc.ini和frps.ini中的配置项tls_cert_file =
frpc-1.xxxx.com.crt、tls_key_file = frpc-1.xxxx.com.key、tls_trusted_ca_file
= frpca.crt如何对应,我感觉我在指定证书配置的时候没有指定正确,目前我对tls证书这块了解不深入,可以举个示例吗。
比如说,我在DigiCert申请后,证书下载Apache类型后有三个文件,分别是: mydomain.key mydomain_chain.crt
(这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书) mydomain_public.crt
那么在frp配置中我应该如何指定tls_cert_file、tls_key_file、tls_trusted_ca_file这三个配置项呢?
或者说我需要下载其他类型的格式? 感谢帮助!

这个证书的问题,最终是怎样填的呢,看了下还是没理解到!


Reply to this email directly, view it on GitHub
https://github.com/fatedier/frp/issues/3484#issuecomment-1672541818, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AM67RQ3ZRKU4MW7D7EYLJ6LXURQUJANCNFSM6AAAAAAZBX724Q
.
You are receiving this because you commented.Message ID:
@.***>

<!-- gh-comment-id:1679906404 --> @limaofu commented on GitHub (Aug 16, 2023): 加我v信, Cof-Lee On Thu, Aug 10, 2023, 12:38 aocheng ***@***.***> wrote: > 你可以参考cof-lee的方档: https://limaofu.github.io/ 代理服务器操作手册-0607-back.docx > <https://limaofu.github.io/t3doc/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C-0607-back.docx> > > 感谢回答,出现这个问题我猜测大概率是证书的问题。通过文对比,有些疑问cof-lee的文档中的样例是否是一个双向验证的样例,是否等价于文档 > 自定义TLS协议加密|frp > <https://gofrp.org/docs/features/common/network/network-tls/#%E5%8F%8C%E5%90%91%E9%AA%8C%E8%AF%81> > 这部分提到的内容?。 我的疑问点在于,如果我使用的不是自签名证书,例如使用Let's Encrypt或者是DigiCert > 生成的证书,我应该下载的是什么格式的证书,并且与frpc.ini和frps.ini中的配置项tls_cert_file = > frpc-1.xxxx.com.crt、tls_key_file = frpc-1.xxxx.com.key、tls_trusted_ca_file > = frpca.crt如何对应,我感觉我在指定证书配置的时候没有指定正确,目前我对tls证书这块了解不深入,可以举个示例吗。 > 比如说,我在DigiCert申请后,证书下载Apache类型后有三个文件,分别是: mydomain.key mydomain_chain.crt > (这个我理解是证书链的中间证书,不确定是否等同于frp文档中提到的ca.crt根证书) mydomain_public.crt > 那么在frp配置中我应该如何指定tls_cert_file、tls_key_file、tls_trusted_ca_file这三个配置项呢? > 或者说我需要下载其他类型的格式? 感谢帮助! > > 这个证书的问题,最终是怎样填的呢,看了下还是没理解到! > > — > Reply to this email directly, view it on GitHub > <https://github.com/fatedier/frp/issues/3484#issuecomment-1672541818>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AM67RQ3ZRKU4MW7D7EYLJ6LXURQUJANCNFSM6AAAAAAZBX724Q> > . > You are receiving this because you commented.Message ID: > ***@***.***> >
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#2785
No description provided.