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()

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

}
相关推荐
Xiaoyu Wang6 小时前
Go协程的调用与原理
开发语言·后端·golang
techdashen14 小时前
性能比拼: Go vs Java
java·开发语言·golang
听雨·眠1 天前
go中map和slice非线程安全
java·开发语言·golang
abin在路上1 天前
Golang 版本导致的容器运行时问题
云原生·golang·containerd
{⌐■_■}1 天前
【go】什么是Go语言的GPM模型?工作流程?为什么Go语言中的GMP模型需要有P?
java·开发语言·后端·golang
why1511 天前
滴滴-golang后端开发-企业事业部门-二面
开发语言·网络·golang
Ai 编码助手1 天前
用Go语言&&正则,如何爬取数据
开发语言·后端·golang
大学生亨亨2 天前
go语言八股文
笔记·golang
web守墓人2 天前
【gpt生成-其二】以go语言为例,详细讲解 并发模型:线程/协程/ Actor 实现
java·gpt·golang
Chandler242 天前
Go:反射
开发语言·后端·golang