Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111
作者:知楠行易
1. 出错环境描述:
web项目升级 https ,配置证书后启动报错。
2. 出错检测
出错的原因:SSL 证书(keystore)配置不正确。修改路径为server.ssl.key-store=classpath:keystore.p12 正常可用。
2.1 检查SSL证书是否正确
keystore.p12 文件检测命令为:
keytool -list -v -keystore path/to/keystore.p12 -storetype PKCS12 -storepass 123456
-list:列出密钥库中的条目。-v:显示详细信息。-storetype:指定密钥库的类型,也就是加密算法类型。-storepass: 指定密钥库的密码。
2.2 检查SSL证书是否有被处理导致文件内容错误
举个例子:
maven 配置了资源文件占位符替换,所以导致二进制文件(.p12)有问题:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<!-- 对资源文件进行占位符替换 -->
<filtering>true</filtering>
</resource>
</resources>
</build>
解决办法:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.p12</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.p12</include>
</includes>
</resource>
</resources>
2.3 检测项目是否有缓存,可以重新构建项目。
2.4 检查文件路径是否正确
可以先配置绝对路径去检测是否找到正确的文件并加载
举个例子,我的证书文件在 /resources-env/dev 下,
└── resources
├── application.properties
├── resources-env
│ ├── dev
│ │ ├── application-dev.properties
│ │ └── keystore.p12
│ └── prod
└── static
└── index.htmlmaven 配置如下:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.p12</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.p12</include>
</includes>
</resource>
<resource>
<directory>src/main/resources-env/${env}</directory>
<filtering>false</filtering>
</resource>
</resources>
配置的地址是:server.ssl.key-store=classpath:/resources-env/dev/keystore.p12 ,会抛出另一个异常:
Caused by: java.io.FileNotFoundException: class path resource [/resources-env/dev/keystore.p12] cannot be resolved to URL because it does not exist
正确的配置应该是:server.ssl.key-store=classpath:keystore.p12。
注意: classpath: 表示从 src/main/resources 开始查找,因此你需要指定完整路径。
正确的配置应该是:server.ssl.key-store=classpath:keystore.p12。
注意: classpath: 表示从 src/main/resources 开始查找,因此你需要指定完整路径。
到此这篇关于Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111, too big.的文章就介绍到这了,更多相关Caused by: java.io.IOException内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
- 解决springboot报错Failed to parse multipart servlet request; nested exception is java.io.IOException问题
- 什么情况下会出现java.io.IOException : Broken pipe这个错误以及解决办法
- 解决Spring调用Feign报错:java.io.IOException:Incomplete output stream问题
- java.io.IOException: UT010029: Stream is closed异常分析及解决
- Android创建文件时出现java.io.IOException: Operation not permitted异常的解决方法
- java.io.IOException:你的主机中的软件中止了一个已建立的连接踩坑实战
- 解决Java中的java.io.IOException: Broken pipe问题
- AndroidApk混淆编译时,报告java.io.IOException...错误解决办法
- JSP上传图片产生 java.io.IOException: Stream closed异常解决方法
