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

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

}
相关推荐
xcLeigh10 小时前
Go入门:无类型常量与类型常量的区别
服务器·开发语言·golang
泡沫冰@10 小时前
GO 语言基础
开发语言·算法·golang
骇客野人14 小时前
电商商城微服务架构设计方案(SpringCloud/Go+Vue3+MySQL+ES+RocketMQ)
spring cloud·微服务·golang
码农大叔的博客15 小时前
golang示例:for九九乘法表
开发语言·算法·golang
圣殿骑士-Khtangc16 小时前
Go-sync-Pool对象池最佳实践与源码分析
golang
互联网中的一颗神经元16 小时前
01. Go 内存管理全景架构
java·jvm·golang
有脚就行16 小时前
第24篇-Go-gRPC推理服务-高性能跨语言通信
开发语言·人工智能·后端·golang
圣殿骑士-Khtangc1 天前
Go-Mutex源码解析从自旋到饥饿模式的完整演进
golang
圣殿骑士-Khtangc2 天前
Go大厂面试真题精讲之并发安全Map的实现方案
golang
运维开发笔记2 天前
3.8 Go switch 语句学习笔记
golang