Golang - http请求InsecureSkipVerify 字段为 true 来忽略忽略 SSL验证

在Golang中,可以通过设置 tls.Config 的 InsecureSkipVerify 字段为 true 来忽略 SSL 验证。

下面是一个简单的示例代码:

Go 复制代码
package main

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

func main() {
	// 创建一个自定义的 Transport
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

	// 创建一个使用自定义 Transport 的 HTTP 客户端
	client := &http.Client{Transport: tr}

	// 发送 GET 请求
	resp, err := client.Get("https://example.com")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	// 读取响应内容
	// ...

}
相关推荐
喵了几个咪1 小时前
GoWind Content Hub|风行,开箱即用的企业级前后端一体内容中台
vue.js·golang·react·taro
人间打气筒(Ada)1 小时前
go实战案例:如何基于 Conul 给微服务添加服务注册与发现?
开发语言·微服务·zookeeper·golang·kubernetes·etcd·consul
superantwmhsxx1 小时前
[golang][MAC]Go环境搭建+VsCode配置
vscode·macos·golang
Cocktail_py2 小时前
Windows直接部署crawlab
windows·python·golang
人间打气筒(Ada)4 小时前
go实战案例:如何在 Go-kit 和 Service Meh 中进行服务注册与发现?
开发语言·后端·golang·istio·go-kit
小白的代码日记4 小时前
区块链分叉检测与回扫系统(Go语言)
人工智能·golang·区块链
brucelee1864 小时前
Windows 11 安装 Go(Golang)教程
开发语言·windows·golang
ruxingli4 小时前
GoLang并发与并行
golang
yuanlaile4 小时前
Golang实现在线教育直播、农场监控直播 幼儿园监控直播
开发语言·后端·golang·go直播实战
onlywhz5 小时前
【Golang】——Gin 框架中间件详解:从基础到实战
中间件·golang·gin