java 连接ftp ssl,JAVA链接FTP异常

JAVA链接FTP错误

本帖最后由 onepiecer1 于 2014-07-03 15:30:47 编辑

之前链接serv-u建立的FTP就没有问题,但是链接IIS建立的FTP就报这个错误。而且直接连接FTP是可以登录访问的。

javax.net.ssl.SSLException: 534-Local policy on server does not allow TLS secure connections.

at org.apache.commons.net.ftp.FTPSClient.execAUTH(FTPSClient.java:227)

at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:210)

at org.apache.commons.net.SocketClient.connect(SocketClient.java:183)

at org.apache.commons.net.SocketClient.connect(SocketClient.java:203)

------解决方案--------------------

需要有支持ftps的客户端

FTP over SSL processing. If desired, the JVM property -Djavax.net.debug=all can be used to see wire-level SSL details.

使用

org.apache.commons.net.ftp.FTPSClient

------解决方案--------------------

这里有个例子看一下吧

/*

* Licensed to the Apache Software Foundation (ASF) under one or more

* contributor license agreements.  See the NOTICE file distributed with

* this work for additional information regarding copyright ownership.

* The ASF licenses this file to You under the Apache License, Version 2.0

* (the "License"); you may not use this file except in compliance with

* the License.  You may obtain a copy of the License at

*

*      http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

package examples;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.io.PrintWriter;

import java.security.NoSuchAlgorithmException;

import org.apache.commons.net.PrintCommandListener;

import org.apache.commons.net.ftp.FTP;

import org.apache.commons.net.ftp.FTPConnectionClosedException;

import org.apache.commons.net.ftp.FTPReply;

import org.apache.commons.net.ftp.FTPSClient;

/***

* This is an example program demonstrating how to use the FTPSClient class.

* This program connects to an FTP server and retrieves the specified

* file.  If the -s flag is used, it stores the local file at the FTP server.

* Just so you can see what's happening, all reply strings are printed.

* If the -b flag is used, a binary transfer is assumed (default is ASCII).

* Usage: ftp [-s] [-b]     

***/

public final class FTPSExample

{

public static final String USAGE =

"Usage: ftp [-s] [-b]     \n" +

"\nDefault behavior is to download a file and use ASCII transfer mode.\n" +

"\t-s store file on server (upload)\n" +

"\t-b use binary transfer mode\n";

public static final void main(String[] args) throws NoSuchAlgorithmException

{

int base = 0;

boolean storeFile = false, binaryTransfer = false, error = false;

String server, username, password, remote, local;

String protocol = "SSL";    // SSL/TLS

FTPSClient ftps;

for (base = 0; base 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值