ssl - Python 的 create_default_context() 等价于 Go?

标签 ssl go ssl-certificate

我正在尝试修改我的 Go 客户端和服务器代码以使用 TLS。在 Python 中我可以做 ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH) 这将自动加载系统的可信 CA 证书并使用安全设置。我想知道 Go 中是否有类似的东西可以自动加载受信任的 CA 证书。我不确定要为客户的证书放什么。

最佳答案

我认为您正在寻找 tls.Config .但请记住,Python 的 ssl.create_default_context 公开了许多大多数人不需要的 SSL 内部结构,您的应用程序中可能不需要 tls.Config全部。例如,net/http 有一个 http.ListenAndServeTLS()使用合理的默认值和您提供的任何证书启动 TLS Web 服务器的函数。

关于ssl - Python 的 create_default_context() 等价于 Go?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50301127/

相关文章:

amazon-web-services - AWS Certificate Manager 和 Elastic BeanSTAlk : Creating an SSL without domain name

ssl - MyDomain.com 仅提供正向 SSL 证书的可复制文本 : one for cert and one for key. 如何在我的 nginx Web 服务器上安装它?

ssl - 关于 SSL session 恢复 : Two piece of material is inconsistent

java - 如何配置 spring boot 应用程序以在 MySQL 上使用 SSL/TLS?

java - PKIX 路径构建失败 - OpenShift 上的 Spring Boot 服务

google-app-engine - 使用应用程序默认凭据模拟服务帐户的用户

amazon-web-services - 如何向 AWS 验证 gocql

go - Response.Body 返回 "empty"正文

java - 尝试从 SSLSocket 读取时获取 EOFException

python - MechanicalSoup 证书验证失败