• notice
  • Congratulations on the launch of the Sought Tech site

Solve the golang https request prompt x509: certificate signed by unknown authority

When using golang as a small crawler, the target URL is an https site that uses a self-signed certificate. When requesting, the error is as follows:

Get https://x.x.x.x/cgi-bin/showflux.cgi: x509: certificate signed by unknown 
authority
panic: Get https://x.x.x.x/cgi-bin/showflux.cgi: x509: certificate signed by
unknown authority

Just for crawling content, you can use the following methods to solve

Step 1:
Import the "crypto/tls" package

Step 2:
Define TLSClientConfig, ignoring certificate verification:

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

Step 3:
Modify

client := &http.Client{}

for

client := &http.Client{Transport: tr}


Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+