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

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

}
相关推荐
Thetimezipsby15 小时前
Go(GoLang)语言基础、知识速查
开发语言·后端·golang
we have a whole life1 天前
Golang(Handler入门)
开发语言·http·golang
molaifeng1 天前
Go 并发控制的艺术:深入理解 context.Context
开发语言·后端·golang
nbsaas-boot1 天前
大系统中 Java 与 Go 的技术选型分析
java·开发语言·golang
Grassto1 天前
Go Module 的版本选择算法:Minimal Version Selection(MVS)
后端·golang·go·go module
天天向上10241 天前
在 Go 的 Gin Web 框架中,获取 HTTP 请求参数有多种方式
前端·golang·gin
特立独行的猫a1 天前
Go应用或二进制应用linux后台稳定运行方案:Docker 与 Systemd 选择指南
linux·docker·golang
molaifeng2 天前
Go runtime 中的 sudog:连接 Channel 与 GMP 的隐秘枢纽
开发语言·golang
羊羊羊i2 天前
使用client-go访问k8s集群
golang·kubernetes
源代码•宸2 天前
goframe框架签到系统项目开发(实现总积分和积分明细接口、补签日期校验)
后端·golang·postman·web·dao·goframe·补签