V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
zhouyou457
V2EX  ›  Java

使用 spring boot 配置 https 出现一个很蛋疼的问题。。

  •  
  •   zhouyou457 · 2017-09-12 13:04:29 +08:00 · 5193 次点击
    这是一个创建于 2664 天前的主题,其中的信息可能已经有所发展或是发生改变。

    报了一个不明所以的错误。。。

    java.lang.IllegalArgumentException: java.net.MalformedURLException: unknown protocol: c
    	at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:114) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:85) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:225) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:990) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:635) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.catalina.connector.Connector.startInternal(Connector.java:1022) [tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) [tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:250) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:193) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    	at com.maxith.SpringCloudEurekaClientApplication.main(SpringCloudEurekaClientApplication.java:17) [classes/:na]
    Caused by: java.net.MalformedURLException: unknown protocol: c
    	at java.net.URL.<init>(URL.java:600) ~[na:1.8.0_73]
    	at java.net.URL.<init>(URL.java:490) ~[na:1.8.0_73]
    	at java.net.URL.<init>(URL.java:439) ~[na:1.8.0_73]
    	at java.net.URI.toURL(URI.java:1089) ~[na:1.8.0_73]
    	at org.apache.tomcat.util.file.ConfigFileLoader.getInputStream(ConfigFileLoader.java:95) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:129) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.SSLHostConfig.getTruststore(SSLHostConfig.java:664) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.jsse.JSSEUtil.getTrustManagers(JSSEUtil.java:256) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:112) ~[tomcat-embed-core-8.5.16.jar:8.5.16]
    	... 19 common frames omitted
    

    追踪源码发现问题:

    下面是 application.properties 的配置文件

    spring.application.name=spring-cloud-eureka-client
    
    server.port=1001
    
    server.ssl.enabled=true
    server.ssl.key-store=classpath:server.jks
    server.ssl.key-store-password=zhouyou457
    

    非常尴尬的是,另一个同样配置的项目却能启动,不知道如何解决,求大神解答

    5 条回复    2017-10-14 22:18:21 +08:00
    andychen20121130
        1
    andychen20121130  
       2017-09-12 15:07:50 +08:00
    java 报错是随机的吧
    lry
        2
    lry  
       2017-09-12 18:46:17 +08:00
    ```java
    2017-09-12 17:44:30.709 INFO 955 --- [https-jsse-nio-443-exec-14] o.a.c.h.Http11Processor : Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

    java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:462) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667) [tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802) [tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) [tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_141]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_141]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.6.jar!/:8.5.6]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
    ```
    搭车同问 SpringBoot SSL 的问题,项目每运行一段时间就会抛出如上异常,网上有些答案说换用 http 就没问题,我想要强制 https...
    wdlth
        3
    wdlth  
       2017-09-12 22:01:07 +08:00
    @lry 看上去是有某些厂商的“态势感知”系统在非法请求
    lry
        4
    lry  
       2017-09-13 10:24:58 +08:00
    @wdlth 某米云主机... 2C4 的配置
    jack80342
        5
    jack80342  
       2017-10-14 22:18:21 +08:00
    这几天翻译了 Spring Boot 最新的官方文档,https://www.gitbook.com/book/jack80342/spring-boot/details
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2589 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 03:12 · PVG 11:12 · LAX 19:12 · JFK 22:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.