12 Replies Latest reply on Aug 29, 2019 6:44 AM by robcob_mc

    JCE cannot authenticate the provider BC

    rhinmass

      I am migrating a webapp from JBoss 4.0.5.GA to JBoss AS7.  I am using 7.1.0.Alpha1-SNAPSHOT. 

       

       

      I am getting the following stack grace on

       

           Cipher.getInstance("AES/CBC/PKCS7Padding", "BC").

       

       

      Caused by: java.lang.SecurityException: JCE cannot authenticate the provider BC

              at javax.crypto.Cipher.getInstance(DashoA13*..) [:1.6]

              at javax.crypto.Cipher.getInstance(DashoA13*..) [:1.6]

              ... 113 more

       

      Caused by: java.util.jar.JarException: Cannot parse vfs:/C:/work/jboss-upgrade/app/src/main/webapp.war/WEB-INF/lib/bcprov-jdk15-136.jar

              at javax.crypto.SunJCE_c.a(DashoA13*..) [:1.6]

              at javax.crypto.SunJCE_b.b(DashoA13*..) [:1.6]

              at javax.crypto.SunJCE_b.a(DashoA13*..) [:1.6]

              at javax.crypto.SunJCE_b.b(DashoA13*..) [:1.6]

              at javax.crypto.Cipher.getInstance(DashoA13*..) [:1.6]

       

      The same war (and bcprov-jdk15-136.jar) runs on 4.0.5.GA.

       

      Any ideas why the AS could not parse the jar file?

        • 1. Re: JCE cannot authenticate the provider BC
          jaikiran
          1 of 1 people found this helpful
          • 2. Re: JCE cannot authenticate the provider BC
            rhinmass

            Any ideas as to a workaround for this problem.  The work arounds described in JBAS-7882 are:

             

            1. move the IAIK library from the ear/war structure to server lib directory, or

            2. expand the ear/war structure in the server deploy directory, or

            3. run the server with property jboss.vfs.forceVfsJar set to true to switch to old jar file handling mechanism (however this old mechanism seems to have some sort of resource leak - it leaves all temporary jar instances it creates in the temporary directory even after clean server shutdown)

             

            However, I don't believe these options are applicable to AS7.

             

            Would I need to create a module for bcprov-jdk15-136.jar ?

            • 3. Re: JCE cannot authenticate the provider BC
              jaikiran

              Robin Hughes wrote:

               

              Any ideas as to a workaround for this problem.  The work arounds described in JBAS-7882 are:

               

               

              2. expand the ear/war structure in the server deploy directory, or

               

              This might be worth a try against AS7. Have you tried deploying your application in exploded format? All you have to do is place the webapp.war in exploded form in JBOSS_HOME/standalone/deployments folder and also a webapp.war.dodeploy marker file to trigger the deployment of the exploded content.

              • 4. Re: JCE cannot authenticate the provider BC
                rhinmass

                This is running from an exploded war. 

                • 5. Re: JCE cannot authenticate the provider BC
                  jaikiran

                  Robin Hughes wrote:

                   

                  This is running from an exploded war. 

                  Thanks for testing that.

                  • 6. Re: JCE cannot authenticate the provider BC
                    rhinmass

                    I think you might have misunderstood my answer.  I have been running from an exploded war all along, and the problem exists.

                     

                    Do you have any other thoughts for work-arounds?  And do you think this fix will be in Alpha1 scheduled for Aug 24?

                     

                    Thanks!!

                    • 7. Re: JCE cannot authenticate the provider BC
                      jaikiran

                      Robin Hughes wrote:

                       

                      I think you might have misunderstood my answer.  I have been running from an exploded war all along, and the problem exists.

                       

                      Ah! I see.

                       

                       

                      Robin Hughes wrote:

                       

                      Do you have any other thoughts for work-arounds?  And do you think this fix will be in Alpha1 scheduled for Aug 24?

                       

                      I'm not aware of any workarounds. I'll check with David and see if we can have a fix for this in one of the upcoming releases.

                      • 8. Re: JCE cannot authenticate the provider BC
                        dmlloyd

                        Yeah this is definitely https://issues.jboss.org/browse/AS7-308 taking effect.  I at least want this fixed for 7.1 if not sooner.

                        • 9. Re: JCE cannot authenticate the provider BC
                          madab

                          Hi,

                           

                          A few days ago I started migrating a webapp from jboss 4 to jboss 7. I downloaded the latest version (7.1.0.CR1b), and I have the same error in my log.

                          I see that the related ticked is fixed. Is there an option or a configuration that I have to make to solve this exception?

                           

                          Thanks in advance,

                          Madalina

                          • 10. Re: JCE cannot authenticate the provider BC
                            jehanzeb.qayyum

                            What are the steps of workaround in Jboss AS 7.1.0Final? Thanks

                            • 11. Re: JCE cannot authenticate the provider BC
                              oman002

                              This workaround in JBoss AS 7.1.1 Final worked for me - How to add bouncycastle to JBoss AS 7.1

                               

                              When migrating an older app make sure you are using bcprov-jdk16 and not the older jdk versions as JBoss 7 uses jdk 1.6+

                              • 12. Re: JCE cannot authenticate the provider BC
                                robcob_mc

                                We have been suffering with the same issue for a few weeks and had tried a lot of the suggested steps to no avail. Providing our solution below so others don't have to suffer like we did!

                                We were attempting to use bcprov-ext-jdk15on-162.jar, added to classpath, included in JBoss lib directories, bundled with WAR, marked as provided and added to JBoss /lib directories but no luck. We were also using JBoss version ~5 eap.

                                In the end, we tried different versions of bouncycastle and found a less recent version who's signature could be verified by our particular Java version's jarsigner (1.5X).

                                Despite the jar's signature being verifiable by our Java version, when the .jar is packaged into a WAR the signature was invalidated somehow by JBoss.

                                In the end, the solution for us was to;

                                1. Add bouncycastle jar to JBoss classpath 
                                2. Add 'org.bouncycastle.jce.provider.BouncyCastleProvider' to 'java.security' providers
                                3. Mark bouncycastle in your WAR as a 'provided' dependency

                                Once we had a version of the .jar on our classpath and were sure that our WAR was not packaging it in we were golden.

                                The issue seems to be tightly coupled to whatever Java/JBoss version you happen to be using. So if this solution does not work for you I would suggest to test different versions of bouncycastle with

                                jarsigner -verify <bouncycastle.jar>