Java/Tomcat アプリケーションで次のエラーが発生します。
Java JRMおよびJDK内のセキュリティポリシーファイルを変更しようとしましたが、それでも同じです...
Tomcat コンソール出力:
java.security.InvalidKeyException: Wrong algorithm: AES or Rijndael required
at com.sun.crypto.provider.SunJCE_c.a(DashoA13*..)
at com.sun.crypto.provider.SunJCE_g.a(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.a(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.a(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineInit(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.a(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at javax.crypto.Cipher.init(DashoA13*..)
at com.illuminati.safemail.util.Util.encryptPrivateKey(Util.java:115)
at com.illuminati.safemail.service.DefaultBusinessServiceImpl.send(DefaultBusinessServiceImpl.java:122)
at com.illuminati.safemail.web.Controller.performAction(Controller.java:83)
at com.illuminati.safemail.web.Controller.doPost(Controller.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
この関数で発生したエラー:
public static synchronized byte[] encryptPrivateKey(
ElGamalPrivateKey privateKey, byte[] hashedAnsBytes)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException,
BadPaddingException, NoSuchProviderException, IOException {
Cipher c = Cipher.getInstance("AES");
SecretKeySpec key = new SecretKeySpec(hashedAnsBytes, "SHA256");
c.init(Cipher.ENCRYPT_MODE, key);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(bos);
out.writeObject(privateKey);
out.close();
bos.close();
byte[] pvtKeyBytes = c.doFinal(bos.toByteArray());
return pvtKeyBytes;
}
助言がありますか?面白いことに、このコードは CentOS マシンで正常に動作します...これには Ubuntu があります。