How to get my Keystore file to work with my Java Vert.x project (Invalid keystore format)











up vote
0
down vote

favorite












I have a Java Vert.x Gradle project and I am trying to get Vert.x auth JWT working with it, but when I run my project I get a Invalid keystore format error.



I am trying to do this locally; I am on an iMac.



Here is part of my build.gradle file:



build.gradle



// Import to replace ant-style tokens (@environmentVariable@) with values
import org.apache.tools.ant.filters.ReplaceTokens

buildscript {
ext.vertxVersion = '3.5.4'
}

dependencies {
compile "io.vertx:vertx-core:$vertxVersion"
compile "io.vertx:vertx-web:$vertxVersion"
compile "io.vertx:vertx-web-client:$vertxVersion"
compile "io.vertx:vertx-web-templ-thymeleaf:3.5.4"
compile "io.vertx:vertx-unit:$vertxVersion"
compile 'io.vertx:vertx-auth-jwt:3.5.4'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
compile "org.slf4j:slf4j-api:1.7.25"
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'com.google.code.gson:gson:2.8.5'
}

//Replace ant-style tokens with properties.
processResources {
filter( ReplaceTokens, tokens: properties )
}


Here is how I am implementing in my Vert.x verticle.



MainVerticle.java



JWTAuthOptions config = new JWTAuthOptions();
config.setKeyStore(new KeyStoreOptions()
.setType(Constants.KEY_STORE_TYPE) /* = "jceks" */
.setPath(Constants.KEY_STORE_PATH) /* = "keystore.jceks" */
.setPassword(Constants.AUTH_KEY_STORE_PASSWORD)); /* correct password */

JWTAuth provider = JWTAuth.create(vertx, config);

router.route(Constants.HOME_PAGE + "/*").handler(JWTAuthHandler.create(provider));


Here is where I am keeping my keystore.jceks file:



keystore.jceks



My-Project
|----src
|----main
|----resources
|----keystore.jceks


I first build my project with gradle:



$ ./gradlew clean build


Building my project works fine. Then I try to run my project:



$ java -jar build/libs/MyProject-far-1.0.jar


When I run my project, I get the following error:



java.lang.RuntimeException: java.io.IOException: Invalid keystore format
at io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl.<init>(JWTAuthProviderImpl.java:107)
at io.vertx.ext.auth.jwt.JWTAuth.create(JWTAuth.java:56)
at com.ucg.warehouselocationmapping.app.MainVerticle.start(MainVerticle.java:54)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:491)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:339)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:745)


I was using this as a reference of how to implement Vert.x auth JWT, as well as another project's code.



The keystore.jceks file I am using was copied from another project where it works perfectly. It was first copied by dragging it around Eclipse. When that didn't work, I tried copying it in the terminal:



$ cp /Users/Me/workspace/My-Service/src/main/resources/keystore.jceks /Users/Me/workspace/My-Project/src/main/resources


That didn't work, so I tried copying it via Finder. That didn't work either.



Anyone ever come across this issue before? I'm not really familiar with jks/jceks files or authentication.



ANSWER



The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



//Replace ant-style tokens with properties.
processResources {
filesMatching('**/*.properties') {
filter( ReplaceTokens, tokens: properties )
}
}









share|improve this question




























    up vote
    0
    down vote

    favorite












    I have a Java Vert.x Gradle project and I am trying to get Vert.x auth JWT working with it, but when I run my project I get a Invalid keystore format error.



    I am trying to do this locally; I am on an iMac.



    Here is part of my build.gradle file:



    build.gradle



    // Import to replace ant-style tokens (@environmentVariable@) with values
    import org.apache.tools.ant.filters.ReplaceTokens

    buildscript {
    ext.vertxVersion = '3.5.4'
    }

    dependencies {
    compile "io.vertx:vertx-core:$vertxVersion"
    compile "io.vertx:vertx-web:$vertxVersion"
    compile "io.vertx:vertx-web-client:$vertxVersion"
    compile "io.vertx:vertx-web-templ-thymeleaf:3.5.4"
    compile "io.vertx:vertx-unit:$vertxVersion"
    compile 'io.vertx:vertx-auth-jwt:3.5.4'
    compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
    compile "org.slf4j:slf4j-api:1.7.25"
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'com.google.code.gson:gson:2.8.5'
    }

    //Replace ant-style tokens with properties.
    processResources {
    filter( ReplaceTokens, tokens: properties )
    }


    Here is how I am implementing in my Vert.x verticle.



    MainVerticle.java



    JWTAuthOptions config = new JWTAuthOptions();
    config.setKeyStore(new KeyStoreOptions()
    .setType(Constants.KEY_STORE_TYPE) /* = "jceks" */
    .setPath(Constants.KEY_STORE_PATH) /* = "keystore.jceks" */
    .setPassword(Constants.AUTH_KEY_STORE_PASSWORD)); /* correct password */

    JWTAuth provider = JWTAuth.create(vertx, config);

    router.route(Constants.HOME_PAGE + "/*").handler(JWTAuthHandler.create(provider));


    Here is where I am keeping my keystore.jceks file:



    keystore.jceks



    My-Project
    |----src
    |----main
    |----resources
    |----keystore.jceks


    I first build my project with gradle:



    $ ./gradlew clean build


    Building my project works fine. Then I try to run my project:



    $ java -jar build/libs/MyProject-far-1.0.jar


    When I run my project, I get the following error:



    java.lang.RuntimeException: java.io.IOException: Invalid keystore format
    at io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl.<init>(JWTAuthProviderImpl.java:107)
    at io.vertx.ext.auth.jwt.JWTAuth.create(JWTAuth.java:56)
    at com.ucg.warehouselocationmapping.app.MainVerticle.start(MainVerticle.java:54)
    at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:491)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:339)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:745)


    I was using this as a reference of how to implement Vert.x auth JWT, as well as another project's code.



    The keystore.jceks file I am using was copied from another project where it works perfectly. It was first copied by dragging it around Eclipse. When that didn't work, I tried copying it in the terminal:



    $ cp /Users/Me/workspace/My-Service/src/main/resources/keystore.jceks /Users/Me/workspace/My-Project/src/main/resources


    That didn't work, so I tried copying it via Finder. That didn't work either.



    Anyone ever come across this issue before? I'm not really familiar with jks/jceks files or authentication.



    ANSWER



    The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



    //Replace ant-style tokens with properties.
    processResources {
    filesMatching('**/*.properties') {
    filter( ReplaceTokens, tokens: properties )
    }
    }









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a Java Vert.x Gradle project and I am trying to get Vert.x auth JWT working with it, but when I run my project I get a Invalid keystore format error.



      I am trying to do this locally; I am on an iMac.



      Here is part of my build.gradle file:



      build.gradle



      // Import to replace ant-style tokens (@environmentVariable@) with values
      import org.apache.tools.ant.filters.ReplaceTokens

      buildscript {
      ext.vertxVersion = '3.5.4'
      }

      dependencies {
      compile "io.vertx:vertx-core:$vertxVersion"
      compile "io.vertx:vertx-web:$vertxVersion"
      compile "io.vertx:vertx-web-client:$vertxVersion"
      compile "io.vertx:vertx-web-templ-thymeleaf:3.5.4"
      compile "io.vertx:vertx-unit:$vertxVersion"
      compile 'io.vertx:vertx-auth-jwt:3.5.4'
      compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
      compile "org.slf4j:slf4j-api:1.7.25"
      testCompile group: 'junit', name: 'junit', version: '4.12'
      implementation 'com.google.code.gson:gson:2.8.5'
      }

      //Replace ant-style tokens with properties.
      processResources {
      filter( ReplaceTokens, tokens: properties )
      }


      Here is how I am implementing in my Vert.x verticle.



      MainVerticle.java



      JWTAuthOptions config = new JWTAuthOptions();
      config.setKeyStore(new KeyStoreOptions()
      .setType(Constants.KEY_STORE_TYPE) /* = "jceks" */
      .setPath(Constants.KEY_STORE_PATH) /* = "keystore.jceks" */
      .setPassword(Constants.AUTH_KEY_STORE_PASSWORD)); /* correct password */

      JWTAuth provider = JWTAuth.create(vertx, config);

      router.route(Constants.HOME_PAGE + "/*").handler(JWTAuthHandler.create(provider));


      Here is where I am keeping my keystore.jceks file:



      keystore.jceks



      My-Project
      |----src
      |----main
      |----resources
      |----keystore.jceks


      I first build my project with gradle:



      $ ./gradlew clean build


      Building my project works fine. Then I try to run my project:



      $ java -jar build/libs/MyProject-far-1.0.jar


      When I run my project, I get the following error:



      java.lang.RuntimeException: java.io.IOException: Invalid keystore format
      at io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl.<init>(JWTAuthProviderImpl.java:107)
      at io.vertx.ext.auth.jwt.JWTAuth.create(JWTAuth.java:56)
      at com.ucg.warehouselocationmapping.app.MainVerticle.start(MainVerticle.java:54)
      at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:491)
      at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:339)
      at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
      at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
      at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      at java.lang.Thread.run(Thread.java:745)


      I was using this as a reference of how to implement Vert.x auth JWT, as well as another project's code.



      The keystore.jceks file I am using was copied from another project where it works perfectly. It was first copied by dragging it around Eclipse. When that didn't work, I tried copying it in the terminal:



      $ cp /Users/Me/workspace/My-Service/src/main/resources/keystore.jceks /Users/Me/workspace/My-Project/src/main/resources


      That didn't work, so I tried copying it via Finder. That didn't work either.



      Anyone ever come across this issue before? I'm not really familiar with jks/jceks files or authentication.



      ANSWER



      The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



      //Replace ant-style tokens with properties.
      processResources {
      filesMatching('**/*.properties') {
      filter( ReplaceTokens, tokens: properties )
      }
      }









      share|improve this question















      I have a Java Vert.x Gradle project and I am trying to get Vert.x auth JWT working with it, but when I run my project I get a Invalid keystore format error.



      I am trying to do this locally; I am on an iMac.



      Here is part of my build.gradle file:



      build.gradle



      // Import to replace ant-style tokens (@environmentVariable@) with values
      import org.apache.tools.ant.filters.ReplaceTokens

      buildscript {
      ext.vertxVersion = '3.5.4'
      }

      dependencies {
      compile "io.vertx:vertx-core:$vertxVersion"
      compile "io.vertx:vertx-web:$vertxVersion"
      compile "io.vertx:vertx-web-client:$vertxVersion"
      compile "io.vertx:vertx-web-templ-thymeleaf:3.5.4"
      compile "io.vertx:vertx-unit:$vertxVersion"
      compile 'io.vertx:vertx-auth-jwt:3.5.4'
      compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
      compile "org.slf4j:slf4j-api:1.7.25"
      testCompile group: 'junit', name: 'junit', version: '4.12'
      implementation 'com.google.code.gson:gson:2.8.5'
      }

      //Replace ant-style tokens with properties.
      processResources {
      filter( ReplaceTokens, tokens: properties )
      }


      Here is how I am implementing in my Vert.x verticle.



      MainVerticle.java



      JWTAuthOptions config = new JWTAuthOptions();
      config.setKeyStore(new KeyStoreOptions()
      .setType(Constants.KEY_STORE_TYPE) /* = "jceks" */
      .setPath(Constants.KEY_STORE_PATH) /* = "keystore.jceks" */
      .setPassword(Constants.AUTH_KEY_STORE_PASSWORD)); /* correct password */

      JWTAuth provider = JWTAuth.create(vertx, config);

      router.route(Constants.HOME_PAGE + "/*").handler(JWTAuthHandler.create(provider));


      Here is where I am keeping my keystore.jceks file:



      keystore.jceks



      My-Project
      |----src
      |----main
      |----resources
      |----keystore.jceks


      I first build my project with gradle:



      $ ./gradlew clean build


      Building my project works fine. Then I try to run my project:



      $ java -jar build/libs/MyProject-far-1.0.jar


      When I run my project, I get the following error:



      java.lang.RuntimeException: java.io.IOException: Invalid keystore format
      at io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl.<init>(JWTAuthProviderImpl.java:107)
      at io.vertx.ext.auth.jwt.JWTAuth.create(JWTAuth.java:56)
      at com.ucg.warehouselocationmapping.app.MainVerticle.start(MainVerticle.java:54)
      at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:491)
      at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:339)
      at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
      at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
      at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      at java.lang.Thread.run(Thread.java:745)


      I was using this as a reference of how to implement Vert.x auth JWT, as well as another project's code.



      The keystore.jceks file I am using was copied from another project where it works perfectly. It was first copied by dragging it around Eclipse. When that didn't work, I tried copying it in the terminal:



      $ cp /Users/Me/workspace/My-Service/src/main/resources/keystore.jceks /Users/Me/workspace/My-Project/src/main/resources


      That didn't work, so I tried copying it via Finder. That didn't work either.



      Anyone ever come across this issue before? I'm not really familiar with jks/jceks files or authentication.



      ANSWER



      The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



      //Replace ant-style tokens with properties.
      processResources {
      filesMatching('**/*.properties') {
      filter( ReplaceTokens, tokens: properties )
      }
      }






      java gradle jwt keystore vert.x






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 3:36

























      asked Nov 19 at 21:10









      aCarella

      83452246




      83452246
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



          //Replace ant-style tokens with properties.
          processResources {
          filesMatching('**/*.properties') {
          filter( ReplaceTokens, tokens: properties )
          }
          }





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382680%2fhow-to-get-my-keystore-file-to-work-with-my-java-vert-x-project-invalid-keystor%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



            //Replace ant-style tokens with properties.
            processResources {
            filesMatching('**/*.properties') {
            filter( ReplaceTokens, tokens: properties )
            }
            }





            share|improve this answer



























              up vote
              0
              down vote



              accepted










              The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



              //Replace ant-style tokens with properties.
              processResources {
              filesMatching('**/*.properties') {
              filter( ReplaceTokens, tokens: properties )
              }
              }





              share|improve this answer

























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



                //Replace ant-style tokens with properties.
                processResources {
                filesMatching('**/*.properties') {
                filter( ReplaceTokens, tokens: properties )
                }
                }





                share|improve this answer














                The import org.apache.tools.ant.filters.ReplaceTokens plugin was finding @ signs in my keystore.jceks file and manipulating them, when I really only wanted ant-style tokens to be replaced in my properties files. I updated my build.gradle file to only replace files ending in .properties, and that fixed my issue.



                //Replace ant-style tokens with properties.
                processResources {
                filesMatching('**/*.properties') {
                filter( ReplaceTokens, tokens: properties )
                }
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 20 at 22:06

























                answered Nov 20 at 14:42









                aCarella

                83452246




                83452246






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382680%2fhow-to-get-my-keystore-file-to-work-with-my-java-vert-x-project-invalid-keystor%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    TypeError: fit_transform() missing 1 required positional argument: 'X'