Apaches FTPSClientを使用してFTPに接続しようとしていますが、次のエラーが発生し続けます。
06-15 09:15:14.749:W / System.err(29451):java.io.IOException:SSLコンテキストを初期化できませんでした
これは次のコードで発生し、エラーは2行目(接続)に発生します。
ftpsClient = new FTPSClient("SSL");
ftpsClient.connect(host);
int reply = ftpsClient.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftpsClient.disconnect();
}
ftpsClient.login(user, password + nl);
ftpsClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpsClient.enterLocalPassiveMode();
私が間違っているかもしれないことの提案はありますか?
編集:
完全なスタックトレース
06-15 09:15:14.749: W/System.err(29451): java.io.IOException: Could not initialize SSL context
06-15 09:15:14.749: W/System.err(29451): at org.apache.commons.net.ftp.FTPSClient.initSslContext(FTPSClient.java:228)
06-15 09:15:14.749: W/System.err(29451): at org.apache.commons.net.ftp.FTPSClient.sslNegotiation(FTPSClient.java:246)
06-15 09:15:14.749: W/System.err(29451): at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:197)
06-15 09:15:14.757: W/System.err(29451): at org.apache.commons.net.SocketClient.connect(SocketClient.java:164)
06-15 09:15:14.757: W/System.err(29451): at org.apache.commons.net.SocketClient.connect(SocketClient.java:184)
06-15 09:15:14.757: W/System.err(29451): at org.apache.commons.net.SocketClient.connect(SocketClient.java:273)
06-15 09:15:14.757: W/System.err(29451): at com.test.FTPClient$getFileListTask.doWhat(FTPClient.java:546)
06-15 09:15:14.757: W/System.err(29451): at com.test.FTPClient$getFileListTask.doInBackground(FTPClient.java:201)
06-15 09:15:14.757: W/System.err(29451): at com.test.FTPClient$getFileListTask.doInBackground(FTPClient.java:1)
06-15 09:15:14.757: W/System.err(29451): at android.os.AsyncTask$2.call(AsyncTask.java:264)
06-15 09:15:14.757: W/System.err(29451): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-15 09:15:14.765: W/System.err(29451): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-15 09:15:14.765: W/System.err(29451): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-15 09:15:14.765: W/System.err(29451): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-15 09:15:14.765: W/System.err(29451): at java.lang.Thread.run(Thread.java:856)
06-15 09:15:14.765: W/System.err(29451): Caused by: java.security.KeyManagementException: No X509KeyManager found
06-15 09:15:14.765: W/System.err(29451): at org.apache.harmony.xnet.provider.jsse.SSLParametersImpl.<init>(SSLParametersImpl.java:116)
06-15 09:15:14.765: W/System.err(29451): at org.apache.harmony.xnet.provider.jsse.SSLContextImpl.engineInit(SSLContextImpl.java:92)
06-15 09:15:14.765: W/System.err(29451): at javax.net.ssl.SSLContext.init(SSLContext.java:219)
06-15 09:15:14.765: W/System.err(29451): at org.apache.commons.net.ftp.FTPSClient.initSslContext(FTPSClient.java:226)
06-15 09:15:14.765: W/System.err(29451): ... 14 more
EDIT2:keymanagerの例外
06-15 10:45:14.886: W/System.err(32467): javax.net.ssl.SSLException: Connection closed by peer
06-15 10:45:14.886: W/System.err(32467): at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
06-15 10:45:14.886: W/System.err(32467): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:410)
06-15 10:45:14.886: W/System.err(32467): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:257)
06-15 10:45:14.886: W/System.err(32467): at org.apache.commons.net.ftp.FTPSClient.sslNegotiation(FTPSClient.java:263)
06-15 10:45:14.886: W/System.err(32467): at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:197)
06-15 10:45:14.886: W/System.err(32467): at org.apache.commons.net.SocketClient.connect(SocketClient.java:164)
06-15 10:45:14.886: W/System.err(32467): at org.apache.commons.net.SocketClient.connect(SocketClient.java:184)
06-15 10:45:14.886: W/System.err(32467): at org.apache.commons.net.SocketClient.connect(SocketClient.java:273)
06-15 10:45:14.886: W/System.err(32467): at com.test.FTPClient$getFileListTask.doWhat(FTPClient.java:552)
06-15 10:45:14.886: W/System.err(32467): at com.test.FTPClient$getFileListTask.doInBackground(FTPClient.java:203)
06-15 10:45:14.886: W/System.err(32467): at com.test.FTPClient$getFileListTask.doInBackground(FTPClient.java:1)
06-15 10:45:14.886: W/System.err(32467): at android.os.AsyncTask$2.call(AsyncTask.java:264)
06-15 10:45:14.894: W/System.err(32467): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-15 10:45:14.894: W/System.err(32467): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-15 10:45:14.901: W/System.err(32467): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-15 10:45:14.901: W/System.err(32467): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-15 10:45:14.901: W/System.err(32467): at java.lang.Thread.run(Thread.java:856)
06-15 10:45:14.901: W/System.err(32467): java.net.SocketException: Socket closed
06-15 10:45:14.909: W/System.err(32467): at libcore.io.Posix.sendtoBytes(Native Method)
06-15 10:45:14.909: W/System.err(32467): at libcore.io.Posix.sendto(Posix.java:146)
06-15 10:45:14.909: W/System.err(32467): at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
06-15 10:45:14.909: W/System.err(32467): at libcore.io.IoBridge.sendto(IoBridge.java:463)
06-15 10:45:14.909: W/System.err(32467): at java.net.PlainSocketImpl.write(PlainSocketImpl.java:507)
06-15 10:45:14.917: W/System.err(32467): at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
06-15 10:45:14.925: W/System.err(32467): at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269)
06-15 10:45:14.925: W/System.err(32467): at java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)
06-15 10:45:14.925: W/System.err(32467): at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158)
06-15 10:45:14.925: W/System.err(32467): at java.io.BufferedWriter.flush(BufferedWriter.java:124)
06-15 10:45:14.925: W/System.err(32467): at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:477)
06-15 10:45:14.925: W/System.err(32467): at org.apache.commons.net.ftp.FTPSClient.sendCommand(FTPSClient.java:486)
06-15 10:45:14.925: W/System.err(32467): at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:537)
06-15 10:45:14.925: W/System.err(32467): at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:586)
06-15 10:45:14.925: W/System.err(32467): at org.apache.commons.net.ftp.FTP.syst(FTP.java:1504)
06-15 10:45:14.933: W/System.err(32467): at org.apache.commons.net.ftp.FTPClient.getSystemType(FTPClient.java:2074)
06-15 10:45:14.933: W/System.err(32467): at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2511)
06-15 10:45:14.933: W/System.err(32467): at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2275)
06-15 10:45:14.933: W/System.err(32467): at com.test.FTPClient$getFileListTask.doWhat(FTPClient.java:298)
06-15 10:45:14.933: W/System.err(32467): at com.test.FTPClient$getFileListTask.doInBackground(FTPClient.java:205)
06-15 10:45:14.933: W/System.err(32467): at com.test.FTPClient$getFileListTask.doInBackground(FTPClient.java:1)
06-15 10:45:14.933: W/System.err(32467): at android.os.AsyncTask$2.call(AsyncTask.java:264)
06-15 10:45:14.933: W/System.err(32467): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-15 10:45:14.933: W/System.err(32467): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-15 10:45:14.933: W/System.err(32467): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-15 10:45:14.933: W/System.err(32467): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-15 10:45:14.933: W/System.err(32467): at java.lang.Thread.run(Thread.java:856)