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

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

}
相关推荐
蓝宝石的傻话14 小时前
因为MiBeeNVR,决定接 onvif-go 自己管理并重构
数码相机·重构·golang
ttwuai20 小时前
Go 后台管理系统组件库文档怎么写,才不会坑后续维护?
开发语言·javascript·golang
2601_9620662321 小时前
golang超详细基础入门教程_golang教程
前端·python·golang
互联网中的一颗神经元1 天前
10. Large 对象分配:直接路径
开发语言·golang
microrain2 天前
从关系库硬扛到专业时序引擎:SagooIoT时序数据存储的架构取舍
物联网·golang·开源·sagooiot
Vect__2 天前
channel 底层剖析
golang
李燚2 天前
数据库迁移不翻车:golang-migrate 实战,143 个 DDL 有序执行(第97篇-E83)
golang·agent·multiagent·migrate·eino·subagent·deepflux
运维开发笔记2 天前
7.1 Go Map 基础
golang
运维开发笔记2 天前
7.2 Go Map 进阶
golang
西瓜很甜哟2 天前
golang每日十题第2期
golang