除了自签名证书之外,是否有办法为 spring boot API 获取从 http 转换为 https 的证书?

Is there a way to get a certificate for spring boot API to convert from http to https other than self signed certificates?

我为我的 API 使用 Spring 引导,我尝试使用自签名证书为我的应用程序启用 https,但是在访问该 firefox 和 chrome 时显示警告说

Warning: Potential Security Risk Ahead with MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT

扑通扑通,邮递员也展示了这个所以我又回到了 http , 那么有没有办法为我的 spring 启动应用程序获取 https 证书?

这里有两种可能

  1. 您需要 HTTPS,因为您希望保护数据传输
  2. 您希望 HTTPS 仅显示 SSL 锁定。以便移动应用程序可以顺利连接。

如果您属于 #1 - 我建议您从任何供应商处购买适当的证书并将其安装在 tomcat 级别,以便您的所有微服务都可以使用它。我从 letsencrypt 获得了 3 个月的免费证书并做了同样的事情。但是,安装可能会非常痛苦,因为您必须将这些证书转换为 JVM 支持的格式等。

如果您属于#2 - 我建议您使用像 cloudflare 这样的反向代理服务。它很容易配置。此外,cloudflare 发布的 SSL 将是免费的。

即您从客户端到 cloudflare 的流量将受到保护并具有 SSL 锁定。但是,从 cloudflare 到您的服务器的流量将是 HTTP。

如果您正在寻找一种免费的方式来获取 https 证书并为您的端点启用 https,您可以通过多种方式来做到这一点。

  • 如果你在云上,那么像 cloudflare 这样的云提供商提供了 ssl 证书的简单集成,所有进出你的云环境的流量都将是 ssl encrypted.AlsoAWS 有以下政策:

When you purchase or transfer a domain name with us you get all those features included:

  • Free domain protection & WHOIS privacy, 5 Email forwards
  • Free SSL Certificate if you also host your website on Cloud CMS
  • Simple DNS Editor to manage your DNS entries (A, CNAME, MX, ...), configure name servers, domain owner, renewal option
  • 另一种方法是在你的机器上设置 Let's encrypt 以每三个月获得一个免费的 ssl 证书,并在你的 springboot 应用程序上使用该证书。该证书默认只有 90 天有效,但 Let's encrypt 提供了一项工作,您可以在您的服务器上 运行 一旦它 expired.Once 您获得 ssl 证书,它将自动更新它,您可以将它添加到通过 application.properties 轻松启动 springboot,如下所示。阅读 guide.

application.properties

server.port=8443
security.require-ssl=true
server.ssl.key-store=/etc/letsencrypt/live/example.com/keystore.p12
server.ssl.key-store-password=<your-password>
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=tomcat