【问题标题】:How gRPC's NewClientTLSFromCert generates TLS credentials from public key?gRPC 的 NewClientTLSFromCert 如何从公钥生成 TLS 凭证?
【发布时间】: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,用于验证服务器证书的真实性。

标签: ssl grpc grpc-go


【解决方案1】:

gRPC 中的传输“凭证”完全负责与客户端/服务器的握手。这意味着它们包括配置,而不仅仅是像私钥和其他秘密这样的“凭证”。对于此处的 TLS,它包括在验证服务器证书时要使用的根信任证书。您可以将其视为“TLS 配置”。

【讨论】:

    猜你喜欢
    • 2017-03-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    • 2012-07-17
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 2019-10-12
    相关资源
    最近更新 更多