Skip to content

x509 certificate verification error #52

@xsm1997

Description

@xsm1997

最新版本会间歇性地报证书错误,如:

http.Client.Do fail:Get "https://59.111.181.38/api/song/detail?ids=%5B26620638%5D": x509: cannot validate certificate for 59.111.181.38 because it doesn't contain any IP SANs

很奇怪的错误,尝试追踪了一下,错误是出在network/network.go的Request函数里面。在这个函数里面,有对HTTPS IP连接的处理,而且这个错误也不能稳定复现,复现概率大概5%左右。对于大多数同样的请求,根本不报错。经过输出request.Host,确定有进入对tls特殊处理的分支中,而且对于url为IP、Host为域名的请求,绝大部分都能正常完成,不报错。

尝试注释掉tr.TLSClientConfig.ServerName = request.Hosttr.TLSClientConfig.InsecureSkipVerify = true之中的一个,均无法解决问题。

为什么会通过IP作为Host来发起https请求?有什么特殊用意吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions