生成的证书移到资源文件夹后停止工作 [英] generated certificate stops working when moved to resources folder

查看:69
本文介绍了生成的证书移到资源文件夹后停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用于连接到Apple Push服务的生成证书存在问题. 当生成的p12文件位于我的src/main/java文件夹中时,一切正常,但是我将其移至src/main/resources,它决定停止处理以下错误:

I'm having problems with a generated certificate I'm using to connect to the apple push services. All works fine when the generated p12 file was in my src/main/java folder, but I moved it to src/main/resources and it decided to stop working with the following error:

DerInputStream.getLength(): lengthTag=111, too big.

进入更多细节: 我正在使用notnoop推送通知库,并按照Ray Wenderlich的教程生成证书.之后,我习惯于遵循以下命令来生成用于Java的p12文件:

To get into some more detail: I'm using the notnoop push notifications library and followed the tutorial from Ray Wenderlich to generate the certificates. after, I used to following commands to generate a p12 file for use in java:

openssl x509 -in aps_development.cer -inform DER -out aps_development.pem -outform PEM
openssl pkcs12 -nocerts -in single.p12 -out single.pem
openssl pkcs12 -export -inkey single.pem -in aps_development.pem -out dual.p12

之后,我将dual.p12移到了我的java项目中.最初,该文件位于我的/src/main/java文件夹中,在com.company.push.certificates下说(而请求文件的代码在com.company.push上).我使用

after that I moved the dual.p12 into my java project. At first the file was in my /src/main/java folder, lets say at com.company.push.certificates (while the code requesting the file is at com.company.push). I request an inputstream by using

InputStream stream = this.getClass().getResourceAsStream("certificates/dual.p12");

这在开发中工作正常,但是在构建项目(使用maven)时却不能,这就是为什么我使用完全相同的包将资源移动到资源文件夹中的原因. 仍然可以找到资源,但是现在我得到了上面提到的java.io.IOException

This working fine in development, but not when building the project (using maven), thats why I moved the resource to the resources folder, using the exact same package. The resource still gets found, but now I get the above-mentioned java.io.IOException

有人知道是什么原因造成的吗?

Anyone knows what might be causing this?

Ps:当我将文件移回到src/main/java中的包中时,所有文件再次正常工作,因此证书似乎有效.

Ps: when I move the file back into the package in src/main/java, all works fine again, so the certificate seems to be valid.

推荐答案

在构建之后,当maven复制到目标/类/...时,检查证书文件的内容.您的构建正在修改文件.验证classes文件夹中的内容与resources文件夹中的内容完全相同.

Check the content of the certificate file AFTER a build, when maven has copied to to target/classes/... Probably maven resource filtering, or something else in your build is modifying the file. Verify what ends up in the classes folder is EXACTLY the same as what is in the resources folder.

http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

这篇关于生成的证书移到资源文件夹后停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆