Maven: resource binary changes file size after build
Asked Answered
M

3

22

I am using the appengine-maven-plugin to build my Java Google App Engine project.

I include .p12 certificates in a WEB-INF sub-folder

When I build my application, the filesize of the certificate increases by a few KB. This renders it invalid. I have seen the same happen to .jks certificates too.

I have verified the validity of the certificate pre-build and used the same method to confirm the invalidity of the post-build certificate.

Can anyone tell me why the file size is changing and why it is not simply copied to the WAR?

Thanks for your help.

Masturbation answered 21/10, 2013 at 16:58 Comment(1)
You should show us your pom, or a pom that can reproduce the issue.Charlyncharm
M
34

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>
Macaroon answered 18/6, 2014 at 9:43 Comment(1)
I had filtering in the maven-war-plugin as well. Disabling it for p12 files fixed the issue.Viewpoint
M
9

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)
Masturbation answered 21/10, 2013 at 18:58 Comment(0)
D
0

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.

Delp answered 15/4, 2015 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.