【发布时间】:2023-02-03 05:07:02
【问题描述】:
google.golang.org/grpc/credentials 库有以下方法。
// NewClientTLSFromCert constructs TLS credentials from the provided root
// certificate authority certificate(s) to validate server connections. If
// certificates to establish the identity of the client need to be included in
// the credentials (eg: for mTLS), use NewTLS instead, where a complete
// tls.Config can be specified.
// serverNameOverride is for testing only. If set to a non empty string,
// it will override the virtual host name of authority (e.g. :authority header
// field) in requests.
func NewClientTLSFromCert(cp *x509.CertPool, serverNameOverride string) TransportCredentials {
return NewTLS(&tls.Config{ServerName: serverNameOverride, RootCAs: cp})
}
我对它如何从公钥(这里的证书)生成 TLS 凭证感到困惑。
这将如何运作?如果我从公共证书生成凭据,为什么它会在其 TLS 证书已使用 TLS CA 的私钥签名的服务器端被接受?
这里到底发生了什么,这里的连接是如何保护的?
【问题讨论】:
-
我读得越多,我认为这仅适用于服务器端 TLS(可能是其他什么),只有在连接时验证服务器。
-
也通过了一些实现代码,这个证书被设置为根CA,用于验证服务器证书的真实性。