当前位置:网站首页>go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
2022-08-11 06:40:00 【咋么又饿了】
一、问题描述:transport: authentication handshake failed: x509: certificate relies on legacy Common Name field, use SANs or temporarily enable
二、背景环境:我的环境windows go 1.17,linux解决这个问题办法同样也适用。
三、首先需要 下载SSL
你点开这个链接以后会看到上面这图片显示的页面,我第一次下载的时候看见有个博客说随便点击一个下载,然后我也没仔细看,因为我的电脑是64位的,我就随便点了一个Win64的,然后好家伙,后面一共卸载下载了三次,不要下载forRAM的,会不允许安装,(ARM64是ARM中64位体系结构,x64是x86系列中的64位体系。ARM属于精简指令集体系,汇编指令比较简单。x86属于复杂指令集体系,汇编指令较多。属于两种不同的体系。看不懂没关系,你只要知道是两种不同的体系,那当然下载了也用不了)不要下载Light的,因为你会找不到后面所需要的openssl.cnf文件。
1、直接根据你的系统去下载最大的那两个其中之一。下载完成以后直接点开exe一直next安装好就可以了。
2、将openSSL的bin目录所在的路径放到path环境变量中,然后重启电脑。
3、生成普通的keyopenssl genrsa -des3 -out server.key 2048
(记住设置的密码,命令直接在终端上执行就好,我直接在goland的终端上执行的)
4、生成ca的crtopenssl req -new -x509 -key server.key -out ca.crt -days 3650
遇到填东西的直接回车就行
5、生成csropenssl req -new -key server.key -out server.csr
6、更改openssl.cnf (Linux 是openssl.cfg)
1)复制一份你安装的openssl的bin目录里面的openssl.cnf 文件到你项目所在的目录,我放在了keys文件夹下。
2)找到 [ CA_default ],打开 copy_extensions = copy (就是把前面的#去掉)
3)找到[ req ],打开 req_extensions = v3_req # The extensions to add to a certificate request
4)找到[ v3_req ],添加 subjectAltName = @alt_names
5)添加新的标签 [ alt_names ],和标签字段
DNS.1 = *.org.haha.com
DNS.2 = *.haha.com
7、生成证书私钥test.keyopenssl genpkey -algorithm RSA -out test.key
8、通过私钥test.key生成证书请求文件test.csr(注意cfg和cnf)
openssl req -new -nodes -key test.key -out test.csr -days 3650 -subj "/C=cn/OU=myorg/O=mycomp/CN=myname" -config ./openssl.cnf -extensions v3_req
test.csr是上面生成的证书请求文件。ca.crt/server.key是CA证书文件和key,用来对test.csr进行签名认证。这两个文件在第一部分生成。
9、生成SAN证书
openssl x509 -req -days 365 -in test.csr -out test.pem -CA ca.crt -CAkey server.key -CAcreateserial -extfile ./openssl.cnf -extensions v3_req
10、然后就可以用在 GO 1.15 以上版本的GRPC通信了
服务器加载代码
creds, err := credentials.NewServerTLSFromFile("test.pem", "test.key")
客户端加载代码
creds,err := credentials.NewClientTLSFromFile("test.pem","*.org.haha.com")


这个问题怎么说呢,试了很多的方法,最终使用这个方法解决了在这里记录一下。
感谢 thankyou~
边栏推荐
- 拼多多API接口大全
- Edge provides label grouping functionality
- Daily sql-statistics of the number of professionals (including the number of professionals is 0)
- 一张图了解JVM八大原子操作
- When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
- Find the shops that have sold more than 1,000 yuan per day for more than 30 consecutive days in the past six months
- 强烈推荐一款好用的API接口
- Douyin API interface
- Tidb二进制集群搭建
- jar服务导致cpu飙升问题-带解决方法
猜你喜欢

恒源云-Pycharm远程训练避坑指南

buu—Re(5)

已解决EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo

Amazon API interface Daquan

技能在赛题解析:交换机防环路设置

Implementation of FIR filter based on FPGA (5) - FPGA code implementation of parallel structure FIR filter

淘宝商品详情API接口

EasyPlayer针对H.265视频不自动播放设置下,loading状态无法消失的解决办法

Taobao sku API interface (PHP example)

Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
随机推荐
js判断图片是否存在
基于FPGA的FIR滤波器的实现(4)— 串行结构FIR滤波器的FPGA代码实现
A used in the study of EEG ultra scanning analysis process
一张图了解JVM八大原子操作
网络电话软件或迎整顿 “免费”通话须迈安全关
Do not add the is prefix to the variables of the boolean type in the POJO class of the Alibaba specification
Pinduoduo api interface application example
Douyin API interface
每日sql-求2016年成功的投资总和
公牛10-11德里克·罗斯最强赛季记录
【latex异常和错误】Missing $ inserted.<inserted text>You can‘t use \spacefactor in math mode.输出文本要注意特殊字符的转义
每日sql:求好友申请通过率
STM32CUBEIDE(11)----输出PWM及修改PWM频率与占空比
每日sql-统计各个专业人数(包括专业人数为0的)
Go语言实现Etcd服务发现(Etcd & Service Discovery & Go)
每日sql -用户两天留存率
Cobbleland 博览会 基础系列 1
《猪猪1984》NFT 作品集将上线 The Sandbox 市场平台
linux 安装mysql服务报错
golang fork 进程的三种方式