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

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

问题描述

我在使用生成的证书连接到 Apple 推送服务时遇到问题.当生成的 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 已复制到 target/classes/... 可能是 maven 资源过滤,或其他内容您的构建正在修改文件.验证类文件夹中的内容与资源文件夹中的内容完全相同.

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天全站免登陆