Maven: resource binary changes file size after build

我只是一个虾纸丫 提交于 2019-11-27 04:24:26

Another solution is to disable filtering of .p12 files throughout your project by adding the following config:

<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-resources-plugin</artifactId>                
      <configuration>
        <nonFilteredFileExtensions>
          <nonFilteredFileExtension>p12</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
      </configuration>
    </plugin>
  </plugins>
</build>

It seems that maven was applying filtering to my certificate file

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

The solution was to disable it

<resource>
    <directory>${basedir}/src/main/webapp/certs</directory>
    <filtering>false</filtering>
    <targetPath>WEB-INF/classes</targetPath>
</resource>

This allowed the certificate to be read correctly and solved the following exception in JavaPNS

Validating keystore reference: VALID  (keystore was found)
Verifying keystore content: javapns.communication.exceptions.KeystoreException:
Keystore exception: DerInputStream.getLength(): lengthTag=111, too big. at javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:178)

I solved the problem by moving '.p12' file one directory up. So instead of keeping it in WEB-INF, I moved it up to 'webapp' directory. No filtering happens there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!