Giter Site home page Giter Site logo

Comments (4)

ericdai avatar ericdai commented on May 24, 2024

根证书不认识,把根证书加入信任列表
或者去掉SSL

from mm-wiki.

jasonyunliang avatar jasonyunliang commented on May 24, 2024

from mm-wiki.

jasonyunliang avatar jasonyunliang commented on May 24, 2024

InsecureSkipVerify: true, 开启这个可以通过。

package main

import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
)

func main() {
client := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
// InsecureSkipVerify 控制client端是否验证服务器的证书链和主机名,
// 如果InsecureSkipVerify为true, crypto/tls接受服务器提供的任务和证书中的任何主机名
// 在这种模式下,tls容易收到中间机器的攻击,除非是用自定义认证,建议只用于测试或者与VerifyConnection或VerifyPeerCertificate一起使用
InsecureSkipVerify: true,
},
},
}

request, err := http.NewRequest("GET", "https://www.baidu.com", nil)
if err != nil {
	panic(err)
}
res, err := client.Do(request)
if err != nil {
	panic(err)
}

defer res.Body.Close()

reply, err := ioutil.ReadAll(res.Body)
if err != nil {
	panic(err)
}

fmt.Println("reply = ", string(reply))

}

from mm-wiki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.