简体   繁体   English

Spring Boot 中基于 URL 的 SSL 证书验证

[英]URL based SSL Certificate Verification in Spring Boot

My requirement is to secure my APIs with SSL using spring boot.我的要求是使用 Spring Boot 使用 SSL 保护我的 API。 I have explored two options我探索了两种选择

      **1. Enable SSL certificate verification for all APIs using application.properties SSL confiuration.
      2. Enable SSL for HTTPS port using application.properties**
      
Is there any way to configure URL(Servlet Path) based SSL certificate verification in Spring boot? .
Like some urls should be consumed by SSL certificate only.

Any help will be greatly appreciated!!!任何帮助将不胜感激!!!

Like some urls should be consumed by SSL certificate only.就像某些 url 应该只由 SSL 证书使用。

For this one, don't think it is possible.对于这一点,不要认为这是可能的。 HTTPS stick to specific port and it is only one port. HTTPS 坚持特定端口,它只是一个端口。 If you deploy your spring boot as Jar and turn on SSL, all connection to that port will be HTTPS.如果您将 Spring Boot 部署为 Jar 并打开 SSL,则到该端口的所有连接都将是 HTTPS。 You need to split your app into two apps in this case, one for HTTP and another for HTTPS.在这种情况下,您需要将您的应用程序拆分为两个应用程序,一个用于 HTTP,另一个用于 HTTPS。

Even you deploy as WAR onto externally provided tomcat, you probably can't run away this, because SSL is restricted to port level.即使您将 WAR 作为 WAR 部署到外部提供的 tomcat,您也可能无法逃避这一点,因为 SSL 仅限于端口级别。 You can refer to this for more if you plan to deploy as WAR.如果您计划部署为 WAR,您可以参考这里了解更多信息。

Updated:更新:

Unless you are ok like what @Sebastian suggested, you can deploy as two port are configured, one is HTTP (80) and another is HTTPS (443).除非你像@Sebastian 建议的那样没问题,否则你可以部署两个端口,一个是 HTTP (80),另一个是 HTTPS (443)。 Then you can use http:// and https:// to achieve your objective, although it doesn't sound like what you want here Is there any way to configure URL(Servlet Path) based SSL certificate verification .然后你可以使用http://https://来实现你的目标,虽然这听起来不像你想要的Is there any way to configure URL(Servlet Path) based SSL certificate verification

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM