vendredi 14 septembre 2012

crash Could not start CRaSSHD Failed to register BouncyCastle as the defaut JCE provider

Problème :

J’ai déployé crash.war dans JBoss et au démarrrage, j’avais l’erreur suivante : Could not start CRaSSHD

10:22:31,335 INFO  [SSHPlugin] Booting SSHD
10:22:32,826 INFO  [SecurityUtils] Trying to register BouncyCastle as a JCE provider
10:22:36,861 SEVERE [SecurityUtils] Failed to register BouncyCastle as the defaut JCE provider
10:22:36,862 SEVERE [SSHLifeCycle] Could not start CRaSSHD

java.lang.RuntimeException: Failed to register BouncyCastle as the defaut JCE provider


Caused by: java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
       at javax.crypto.SunJCE_b.a(DashoA13*..)
       at javax.crypto.KeyAgreement.getInstance(DashoA13*..)
       at org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration.run(SecurityUtils.java:97)
       at org.apache.sshd.common.util.SecurityUtils.register(SecurityUtils.java:77)
       ... 79 more
Caused by: java.util.jar.JarException: Cannot parse jar:file:/opt/jboss/jboss-eap-5.1/jboss-as/server/all/deploy/crash.war!/WEB-INF/lib/bcprov-jdk16-1.46.jar


Solution :

- Récupérer les fichiers (Dans mon cas bcprov-jdk15on-147.jar et bcprov-ext-jdk15on-147.jar).
http://www.bouncycastle.org/latest_releases.html
- Copier ses fichiers (e.g:bcprov-jdk15on-147.jar et bcprov-ext-jdk15on-147.jar) dans /opt/jdk/jdk1.6.0_18/jre/lib/ext
- vi /path_to_your_jvm/jre/lib/security/java.security et ajouter la ligne security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider

security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.sun.net.ssl.internal.ssl.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=com.sun.security.sasl.Provider
security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.8=sun.security.smartcardio.SunPCSC
security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider

- Redémarrer jboss.

http://www.randombugs.com/java/javalangsecurityexception-jce-authenticate-provider-bc.html
http://nyal.developpez.com/tutoriel/java/bouncycastle/#L1

http://julienviet.com/crash/