So, I finally got the right combination of padding schemes, third party providers, etc. and my encryption was working. I had code that created an RSA key from bytes received from a C++ program, used that key to then encrypt (with bouncy Castle) a triple-DES key in order to
exchange it securely before using it for encrypting/decrypting data.
I was running my webapp through eclipse (the Jetty attachment) and everything worked. When I took it out of this environment and tried it in a runtime environment, I get the crash stack below. Weird thing is I would expect the Bouncy Castle, if anything to give me problems, but not the standard SunJCE provider.
- I've checked most/all(?) places where the sunjce_provider.jar should be, and I think its in place.
- I've checked what was going on in Eclipse's JRE in order to make sure that my jetty server will be running the same jars, and AsFarAsICanTell, everything's looking good.
If anyone has some ideas on what else I should check here, please let me know.
JRE version is 1.4.2_04
CryptoUtils.java:180:
>>>>>>>>>>>>>>>>>>>>>>>>>>>
java.lang.ExceptionInInitializerError
at javax.crypto.Cipher.a(DashoA6275)
at javax.crypto.Cipher.getInstance(DashoA6275)
at com.mqsoftware.utils.CryptoUtils.desEdeEncrypt(CryptoUtils.java:180)
at com.mqsoftware.imp.config.mqseries.MQMessageBrowser.encrypt(MQMessageBrowser.java:349)
at com.mqsoftware.imp.config.mqseries.MQMessageBrowser.putMessage(MQMessageBrowser.java:127)
at com.mqsoftware.servlets.PutMessage.doPost(PutMessage.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:196)
at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:125)
at com.mqsoftware.servlets.SetAndPutMessage.doPost(SetAndPutMessage.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1723)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:514)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1673)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:783)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:945)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:800)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:454)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
... 28 more
Caused by: java.security.PrivilegedActionException: java.security.NoSuchAlgorithmException: MD5WITHRSA Signature not available
at java.security.AccessController.doPrivileged(Native Method)
... 29 more
Caused by: java.security.NoSuchAlgorithmException: MD5WITHRSA Signature not available
at java.security.Security.getEngineClassName(Security.java:584)
at java.security.Security.getEngineClassName(Security.java:595)
at java.security.Security.getImpl(Security.java:1044)
at java.security.Signature.getInstance(Signature.java:169)
at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:425)
at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:383)
at javax.crypto.SunJCE_b.c(DashoA6275)
at javax.crypto.SunJCE_b.b(DashoA6275)
at javax.crypto.SunJCE_s.run(DashoA6275)
... 30 more
getException():
java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
at javax.crypto.Cipher.a(DashoA6275)
at javax.crypto.Cipher.getInstance(DashoA6275)
at com.mqsoftware.utils.CryptoUtils.desEdeEncrypt(CryptoUtils.java:180)
at com.mqsoftware.imp.config.mqseries.MQMessageBrowser.encrypt(MQMessageBrowser.java:349)
at com.mqsoftware.imp.config.mqseries.MQMessageBrowser.putMessage(MQMessageBrowser.java:127)
at com.mqsoftware.servlets.PutMessage.doPost(PutMessage.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:196)
at org.mortbay.jetty.servlet.Dispatcher.include(Dispatcher.java:125)
at com.mqsoftware.servlets.SetAndPutMessage.doPost(SetAndPutMessage.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:356)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1723)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:514)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1673)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:783)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:945)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:800)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:454)
Caused by: java.security.PrivilegedActionException: java.security.NoSuchAlgorithmException: MD5WITHRSA Signature not available
at java.security.AccessController.doPrivileged(Native Method)
... 29 more
Caused by: java.security.NoSuchAlgorithmException: MD5WITHRSA Signature not available
at java.security.Security.getEngineClassName(Security.java:584)
at java.security.Security.getEngineClassName(Security.java:595)
at java.security.Security.getImpl(Security.java:1044)
at java.security.Signature.getInstance(Signature.java:169)
at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:425)
at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:383)
at javax.crypto.SunJCE_b.c(DashoA6275)
at javax.crypto.SunJCE_b.b(DashoA6275)
at javax.crypto.SunJCE_s.run(DashoA6275)
... 30 more