Home > Backend Development > Golang > Why Does My Golang HTTP Request Fail with 'x509: certificate signed by unknown authority' on Windows XP?

Why Does My Golang HTTP Request Fail with 'x509: certificate signed by unknown authority' on Windows XP?

Barbara Streisand
Release: 2024-11-11 20:03:03
Original
317 people have browsed it

Why Does My Golang HTTP Request Fail with

Certificate Validation Error in Windows XP for Golang HTTP x509

Problem:

When running a client app using Golang 1.9.2 on Windows XP, users encounter the error "x509: certificate signed by unknown authority" during HTTP GET and POST requests, even though the certificate is valid and signed by a trusted authority.

Background:

This error occurs when the client is unable to verify the server's certificate chain because the intermediate certificates necessary for validation are not installed in the host system's certificate store.

Attempted Solution:

To resolve the issue, the user implemented the following code based on advice from other sources:

tr := &http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkyVerify: true},
}
Copy after login

However, this solution is incorrect, as the field name is "InsecureSkipVerify" instead of "InsecureSkyVerify".

Correct Solution:

The correct implementation should be:

tr := &http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
Copy after login

Warning:

Please exercise caution when using "InsecureSkipVerify" as it disables server certificate validation and hostname checks. This can expose the client to security risks, such as man-in-the-middle attacks. It is recommended to use custom verification or "VerifyConnection" or "VerifyPeerCertificate" for a secure connection.

The above is the detailed content of Why Does My Golang HTTP Request Fail with 'x509: certificate signed by unknown authority' on Windows XP?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template