Требуется шифр 'aes256-cbc', но он недоступен

Я пытаюсь выполнить SFTP с помощью JSch, но я столкнулся с некоторой ошибкой:

com.jcraft.jsch.JSchException: требуется шифр 'aes256-cbc', но он недоступен.

Ниже приведен код, который я использовал. Есть что-то, что я пропустил?

JSch jsch = new JSch();
Session session = null;

jsch.addIdentity("C:\\privatekey.ppk", "Password");

session = jsch.getSession("user", "54.251.240.234", 22);
session.setConfig("StrictHostKeyChecking", "no");


Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.put("C:\\Users\\test.txt", "/home/user/test.txt");
sftpChannel.exit();
session.disconnect();

Stacktrace

[8/30/13 1:56:26:556 SGT] 00000021 SystemErr     R com.jcraft.jsch.JSchException: The cipher 'aes256-cbc' is required, but it is not available.
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr     R  at com.jcraft.jsch.KeyPair.loadPPK(KeyPair.java:1017)
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr     R  at com.jcraft.jsch.KeyPair.load(KeyPair.java:590)
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr     R  at com.jcraft.jsch.KeyPair.load(KeyPair.java:542)
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr     R  at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr     R  at com.jcraft.jsch.JSch.addIdentity(JSch.java:389)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr     R  at com.jcraft.jsch.JSch.addIdentity(JSch.java:370)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr     R  at com.belsize.sb.SB_UtilityBean.runExternalProgram_Windows(SB_UtilityBean.java:1134)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr     R  at com.belsize.sb.EJSLocal0SLSB_Utility_861cc9f0.runExternalProgram_Windows(EJSLocal0SLSB_Utility_861cc9f0.java)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr     R  at com.belsize.sb.SB_IntegrationBean.getFTP_Status(SB_IntegrationBean.java:2175)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr     R  at com.belsize.sb.EJSLocal0SLSB_Integration_13682180.getFTP_Status(EJSLocal0SLSB_Integration_13682180.java)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr     R  at pagecode.module.user_permission.W_useraccount.getFTP_Status(W_useraccount.java:992)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr     R  at pagecode.module.user_permission.Up1006.doUp1006_commandlink_testftpAction(Up1006.java:711)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr     R  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr     R  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr     R  at java.lang.reflect.Method.invoke(Method.java:611)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr     R  at org.apache.el.parser.AstValue.invoke(AstValue.java:268)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr     R  at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr     R  at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr     R  at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:88)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr     R  at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:100)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr     R  at javax.faces.component.UICommand.broadcast(UICommand.java:120)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr     R  at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:973)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr     R  at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:275)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr     R  at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1285)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr     R  at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:711)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr     R  at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr     R  at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr     R  at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr     R  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1225)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:775)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:457)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr     R  at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:77)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr     R  at com.belsize.servlet.filter.RedirectLogin.doFilter(RedirectLogin.java:177)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:908)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr     R  at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr     R  at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:166)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr     R  at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr     R  at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr     R  at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr     R  at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr     R  at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr     R  at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr     R  at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1691)

Ответ 1

Эта ошибка также появляется, когда ваш закрытый ключ находится в формате замазки, а не в открытом формате ssh.

Вы можете преобразовать ключ с помощью инструмента puttygen в открытый закрытый ключ ssh.

Это решает проблему для меня. Для замены файлов Java в моем случае не было необходимости с netbeans 8.0.2 и Java 8_25.

Ответ 2

По умолчанию политики JCE, которые поставляются вместе с JDK или JRE, не поддерживают такие методы шифрования, как (ase-256,.. и т.д.).

Конечно, вы ДОЛЖНЫ заменить ваши текущие JCE-банки (существуют на $JAVA_HOME/jre/lib/security) с совместимой версией Jave, которую вы имеете на веб-сайте oracle.

  • Ссылки для скачивания:

Для JDK 1.6: http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html Исправленная ссылка

Для JDK 1.7: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html

Для JDK 1.8: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

Это устранит проблему.

Ответ 3

Вам нужно добавить в свою политику безопасности JRE - java без ограничений, например: http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html Пожалуйста, замените local_policy и us_export_policy на сервере JRE path (\ Lib\безопасность) Другая версия политики JCE может быть найдена на веб-страницах оракула. ​​