- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试连接到 FTPS 服务器。我可以很好地连接 FileZilla 并列出服务器中的文件、下载等..
我正在尝试使用 org.apache.commons.net.ftp 包中的 FTPSClient 通过 Java 连接到此 FTP 服务器。这就是我正在尝试的方法:
FTPSClient ftp = new FTPSClient();
ftp.connect(HOST, 7021);
ftp.enterLocalPassiveMode();
ftp.login(USERNAME, PASSWORD);
final int list = ftp.list();
System.out.println("List returned: " + list);
我得到的回应是:
List returned: 425
根据Wikipedia , 425 表示:“无法打开数据连接。”
但是,尝试创建文件夹效果很好:
FTPSClient ftp = new FTPSClient();
ftp.connect(HOST, 7021);
ftp.enterLocalPassiveMode();
ftp.login(USERNAME, PASSWORD);
ftp.mkd("/laylaylom");
因此,如果我运行此代码并与 FileZilla 连接,我将在 FTP 服务器中看到文件夹“laylaylom”。
我也尝试过:
FTPSClient ftp = new FTPSClient();
ftp.connect(HOST, 7021);
ftp.login(USERNAME, PASSWORD);
final int pasv = ftp.sendCommand("PASV");
System.out.println("pasv is: " + pasv);
final int list = ftp.list();
System.out.println("List returned: " + list);
输出将是:
pasv is: 227
List returned: 522
其中 227 是:“进入被动模式 (h1,h2,h3,h4,p1,p2)。”维基百科页面中没有列出 552,我不确定它代表什么。
如何使 list()
工作?
编辑#1
在 Martin Prikryl 回答之后我尝试了这个:
FTPSClient ftp = new FTPSClient();
ftp.connect(HOST, 7021);
ftp.enterLocalPassiveMode();
ftp.login(USERNAME, PASSWORD);
final FTPFile[] ftpFiles = ftp.mlistDir("/");
System.out.println(ftpFiles.length);
返回 0..
编辑#2WinSCP 日志:
. 2016-11-24 12:52:33.947 --------------------------------------------------------------------------
. 2016-11-24 12:52:33.947 WinSCP Version 5.9.2 (Build 6958) (OS 6.1.7601 Service Pack 1 - Windows 7 Home Premium)
. 2016-11-24 12:52:33.947 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2016-11-24 12:52:33.947 Log level: Normal
. 2016-11-24 12:52:33.947 Local account: KORAYTUGAY6639\koraytugay
. 2016-11-24 12:52:33.947 Working directory: C:\Program Files (x86)\WinSCP
. 2016-11-24 12:52:33.947 Process ID: 3220
. 2016-11-24 12:52:33.947 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe"
. 2016-11-24 12:52:33.947 Time zone: Current: GMT+2, Standard: GMT+2 (E. Europe Standard Time), DST: GMT+3 (E. Europe Daylight Time), DST Start: 3/27/2016, DST End: 10/30/2016
. 2016-11-24 12:52:33.947 Login time: Thursday, November 24, 2016 12:52:33 PM
. 2016-11-24 12:52:33.947 --------------------------------------------------------------------------
. 2016-11-24 12:52:33.947 Session name: tuimcardtest@files.innbound.net (Ad-Hoc site)
. 2016-11-24 12:52:33.947 Host name: files.innbound.net (Port: 7021)
. 2016-11-24 12:52:33.947 User name: tuimcardtest (Password: Yes, Key file: No)
. 2016-11-24 12:52:33.947 Transfer Protocol: FTP
. 2016-11-24 12:52:33.947 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec
. 2016-11-24 12:52:33.947 Disable Nagle: No
. 2016-11-24 12:52:33.947 Proxy: None
. 2016-11-24 12:52:33.947 Send buffer: 262144
. 2016-11-24 12:52:33.947 UTF: Auto
. 2016-11-24 12:52:33.947 FTPS: Explicit TLS/SSL [Client certificate: No]
. 2016-11-24 12:52:33.947 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto
. 2016-11-24 12:52:33.947 Session reuse: Yes
. 2016-11-24 12:52:33.947 TLS/SSL versions: TLSv1.0-TLSv1.2
. 2016-11-24 12:52:33.947 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2016-11-24 12:52:33.947 Cache directory changes: Yes, Permanent: Yes
. 2016-11-24 12:52:33.947 Recycle bin: Delete to: No, Overwritten to: No, Bin path:
. 2016-11-24 12:52:33.947 Timezone offset: 0h 0m
. 2016-11-24 12:52:33.947 --------------------------------------------------------------------------
. 2016-11-24 12:52:34.009 Connecting to files.innbound.net:7021 ...
. 2016-11-24 12:52:34.009 Connected with files.innbound.net:7021, negotiating TLS connection...
< 2016-11-24 12:52:34.071 220 Welcome to THE FTP service.
> 2016-11-24 12:52:34.071 AUTH TLS
< 2016-11-24 12:52:34.149 234 Proceed with negotiation.
. 2016-11-24 12:52:34.212 Server asks for authentication with a client certificate.
. 2016-11-24 12:52:34.290 Verifying certificate for "Innflow" with fingerprint 54:52:0f:a0:cc:6a:38:80:d5:52:cc:9d:a4:4f:19:4a:d9:50:08:a7 and 18 failures
. 2016-11-24 12:52:34.290 Asking user:
. 2016-11-24 12:52:34.290 **The server's certificate is not known. You have no guarantee that the server is the computer you think it is.**
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Server's certificate details follow:
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Issuer:
. 2016-11-24 12:52:34.290 - Organization: Innflow, innbound.net, patrick.meier@innflow.com
. 2016-11-24 12:52:34.290 - Location: CH, Zurich, Zurich
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Subject:
. 2016-11-24 12:52:34.290 - Organization: Innflow, innbound.net, patrick.meier@innflow.com
. 2016-11-24 12:52:34.290 - Location: CH, Zurich, Zurich
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Valid: 7/6/2010 11:42:44 PM - 7/3/2020 11:42:44 PM
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Fingerprint (SHA-1): 54:52:0f:a0:cc:6a:38:80:d5:52:cc:9d:a4:4f:19:4a:d9:50:08:a7
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Summary: Self-signed certificate. The error occurred at a depth of 1 in the certificate chain.
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Certificate was not issued for this server. You might be connecting to a server that is pretending to be "files.innbound.net".
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 If you trust this certificate, press Yes. To connect without storing certificate, press No. To abandon the connection press Cancel.
. 2016-11-24 12:52:34.290
. 2016-11-24 12:52:34.290 Continue connecting and store the certificate? ()
. 2016-11-24 12:52:35.725 Using TLSv1, cipher TLSv1/SSLv3: AES128-SHA, 1024 bit RSA, AES128-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(128) Mac=SHA1
. 2016-11-24 12:52:35.787 TLS connection established. Waiting for welcome message...
> 2016-11-24 12:52:35.787 USER tuimcardtest
< 2016-11-24 12:52:35.803 331 Please specify the password.
> 2016-11-24 12:52:35.803 PASS ************
< 2016-11-24 12:52:35.865 230 Login successful.
> 2016-11-24 12:52:35.865 SYST
< 2016-11-24 12:52:35.928 215 UNIX Type: L8
> 2016-11-24 12:52:35.928 FEAT
< 2016-11-24 12:52:36.006 211-Features:
< 2016-11-24 12:52:36.006 AUTH SSL
< 2016-11-24 12:52:36.006 AUTH TLS
< 2016-11-24 12:52:36.006 EPRT
< 2016-11-24 12:52:36.006 EPSV
< 2016-11-24 12:52:36.068 MDTM
< 2016-11-24 12:52:36.068 PASV
< 2016-11-24 12:52:36.068 PBSZ
< 2016-11-24 12:52:36.068 PROT
< 2016-11-24 12:52:36.068 REST STREAM
< 2016-11-24 12:52:36.068 SIZE
< 2016-11-24 12:52:36.068 TVFS
< 2016-11-24 12:52:36.068 UTF8
< 2016-11-24 12:52:36.068 211 End
> 2016-11-24 12:52:36.068 OPTS UTF8 ON
< 2016-11-24 12:52:36.131 200 Always in UTF8 mode.
> 2016-11-24 12:52:36.131 PBSZ 0
< 2016-11-24 12:52:36.209 200 PBSZ set to 0.
> 2016-11-24 12:52:36.209 PROT P
< 2016-11-24 12:52:36.271 200 PROT now Private.
. 2016-11-24 12:52:36.287 Connected
. 2016-11-24 12:52:36.287 --------------------------------------------------------------------------
. 2016-11-24 12:52:36.287 Using FTP protocol.
. 2016-11-24 12:52:36.287 Doing startup conversation with host.
> 2016-11-24 12:52:36.349 PWD
< 2016-11-24 12:52:36.411 257 "/"
. 2016-11-24 12:52:36.411 Getting current directory name.
. 2016-11-24 12:52:36.599 Retrieving directory listing...
> 2016-11-24 12:52:36.599 TYPE A
< 2016-11-24 12:52:36.661 200 Switching to ASCII mode.
> 2016-11-24 12:52:36.661 PASV
< 2016-11-24 12:52:36.739 227 Entering Passive Mode (46,140,133,66,195,80).
> 2016-11-24 12:52:36.739 LIST -a
. 2016-11-24 12:52:36.739 Connecting to 46.140.133.66:50000 ...
. 2016-11-24 12:52:36.879 Session ID reused
< 2016-11-24 12:52:36.879 150 Here comes the directory listing.
. 2016-11-24 12:52:36.879 Using TLSv1, cipher TLSv1/SSLv3: AES128-SHA, 1024 bit RSA, AES128-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(128) Mac=SHA1
. 2016-11-24 12:52:36.911 TLS connection established
. 2016-11-24 12:52:37.020 drwxrwsrwx 6 0 1004 4096 Nov 24 08:32 .
. 2016-11-24 12:52:37.020 drwxrwsrwx 6 0 1004 4096 Nov 24 08:32 ..
. 2016-11-24 12:52:37.020 -rw-r--r-- 1 1004 1004 162000 Oct 28 15:25 YTF.AR.T700.S.E0089858.D161028.T092339.A001
. 2016-11-24 12:52:37.020 drwxr-sr-x 2 1004 1004 4096 Nov 24 07:29 abc
. 2016-11-24 12:52:37.020 drwxr-sr-x 2 1004 1004 4096 Nov 24 07:14 koray
. 2016-11-24 12:52:37.020 drwxr-sr-x 2 1004 1004 4096 Nov 24 08:32 laylaylom
. 2016-11-24 12:52:37.020 drwxr-sr-x 2 1004 1004 4096 Nov 24 07:15 tugay
< 2016-11-24 12:52:37.160 226 Directory send OK.
. 2016-11-24 12:52:37.160 Directory listing successful
. 2016-11-24 12:52:37.160 Detecting timezone difference...
. 2016-11-24 12:52:37.160 Retrieving file information...
> 2016-11-24 12:52:37.160 PWD
< 2016-11-24 12:52:37.223 257 "/"
> 2016-11-24 12:52:37.223 CWD /YTF.AR.T700.S.E0089858.D161028.T092339.A001
< 2016-11-24 12:52:37.285 550 Failed to change directory.
> 2016-11-24 12:52:37.285 TYPE I
< 2016-11-24 12:52:37.363 200 Switching to Binary mode.
> 2016-11-24 12:52:37.363 SIZE /YTF.AR.T700.S.E0089858.D161028.T092339.A001
< 2016-11-24 12:52:37.425 213 162000
> 2016-11-24 12:52:37.425 MDTM /YTF.AR.T700.S.E0089858.D161028.T092339.A001
< 2016-11-24 12:52:37.488 213 20161028152533
. 2016-11-24 12:52:37.488 Retrieving file information successful
. 2016-11-24 12:52:37.488 Timezone difference of -3 detected using file /YTF.AR.T700.S.E0089858.D161028.T092339.A001 (Listing: 2016-10-28T12:25:00.000Z, UTF: 2016-10-28T15:25:00.000Z)
. 2016-11-24 12:52:37.488 ..;D;0;1899-12-30T02:00:00.000Z;0;"" [0];"" [0];---------;0
. 2016-11-24 12:52:37.488 YTF.AR.T700.S.E0089858.D161028.T092339.A001;-;162000;2016-10-28T15:25:00.000Z;1;"1004" [0];"1004" [0];rw-r--r--;0
. 2016-11-24 12:52:37.488 abc;D;0;2016-11-24T08:29:00.000Z;1;"1004" [0];"1004" [0];rwxr-sr-x;0
. 2016-11-24 12:52:37.488 koray;D;0;2016-11-24T08:14:00.000Z;1;"1004" [0];"1004" [0];rwxr-sr-x;0
. 2016-11-24 12:52:37.488 laylaylom;D;0;2016-11-24T09:32:00.000Z;1;"1004" [0];"1004" [0];rwxr-sr-x;0
. 2016-11-24 12:52:37.488 tugay;D;0;2016-11-24T08:15:00.000Z;1;"1004" [0];"1004" [0];rwxr-sr-x;0
. 2016-11-24 12:52:37.597 Startup conversation with host finished.
. 2016-11-24 13:54:14.249 Dummy directory read to keep session alive.
. 2016-11-24 13:54:14.249 Retrieving directory listing...
> 2016-11-24 13:54:14.249 TYPE A
< 2016-11-24 13:54:14.312 200 Switching to ASCII mode.
> 2016-11-24 13:54:14.312 PASV
< 2016-11-24 13:54:14.390 227 Entering Passive Mode (46,140,133,66,195,81).
> 2016-11-24 13:54:14.390 LIST -a
. 2016-11-24 13:54:14.390 Connecting to 46.140.133.66:50001 ...
< 2016-11-24 13:54:14.514 150 Here comes the directory listing.
. 2016-11-24 13:54:14.514 Session ID reused
. 2016-11-24 13:54:14.530 Using TLSv1, cipher TLSv1/SSLv3: AES128-SHA, 1024 bit RSA, AES128-SHA SSLv3 Kx=RSA Au=RSA Enc=AES(128) Mac=SHA1
. 2016-11-24 13:54:14.530 TLS connection established
. 2016-11-24 13:54:14.655 drwxrwsrwx 6 0 1004 4096 Nov 24 08:32 .
. 2016-11-24 13:54:14.655 drwxrwsrwx 6 0 1004 4096 Nov 24 08:32 ..
. 2016-11-24 13:54:14.655 -rw-r--r-- 1 1004 1004 162000 Oct 28 15:25 YTF.AR.T700.S.E0089858.D161028.T092339.A001
. 2016-11-24 13:54:14.655 drwxr-sr-x 2 1004 1004 4096 Nov 24 07:29 abc
. 2016-11-24 13:54:14.655 drwxr-sr-x 2 1004 1004 4096 Nov 24 07:14 koray
. 2016-11-24 13:54:14.655 drwxr-sr-x 2 1004 1004 4096 Nov 24 08:32 laylaylom
. 2016-11-24 13:54:14.655 drwxr-sr-x 2 1004 1004 4096 Nov 24 07:15 tugay
< 2016-11-24 13:54:14.795 226 Directory send OK.
. 2016-11-24 13:54:14.795 Directory listing successful
最佳答案
FTP.list
method实在是太低级了。它甚至不打开数据连接。它只发送 LIST
命令。您不能单独使用它。正如其文档所述:
<小时/>A convenience method to send the FTP LIST command to the server,receive the reply, and return the reply code. Remember, it is upto you to manage the data connection. If you don't need this lowlevel of access, use
FTPClient
, which will handle all low level details for you.
相反,使用一些高级方法,例如:
FTPClient.mlistDir
(推荐,如果服务器支持)或FTPClient.listFiles
.并保持您的第一种方法,即调用 FTPClient.enterLocalPassiveMode()
。
仅通过向服务器发送PASV
命令无法切换到被动模式。您还必须切换客户端。否则客户端和服务器将无法相互通信。
FTPClient.enterLocalPassiveMode
将客户端和服务器都切换到被动模式。
当您使用 FTPS 时,您还需要启用加密数据传输。请注意,Apache Common Net 库默认情况下不会加密数据传输。
ftp.execPBSZ(0);
ftp.execPROT("P").
实际上,如果控制连接已加密,某些服务器(特别是您的服务器)甚至会要求您加密数据传输。
关于java - org.apache.commons.net.ftp.FTPSClient 在列表命令后返回 425,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40780458/
最近,我开始学习 cuis-smalltalk,我没有意识到与 CLOS 相比,Smalltalk 的 OOP 有多么深刻和深入(我使用的是 Ruby)。我了解到 Smalltalk 是一个自己实现的
Maven存储库包含以下两个依赖项:org.apache.commons:commons-io:1.3.2和commons-io:commons-io:1.3.2。有什么区别,我应该在pom.xml中
我刚刚在我的 pom 文件中看到 Apache commons-collections 有两个不同的组 ID: commons-collections commons-collect
Windows 上的 Common Lisp 中是否有用于串行端口通信的库? 最佳答案 下面是一些使用 SBCL 外部函数 POSIX 调用实现串行通信的函数。它不如完整的库好,但我解决了根据此协议(
SBCL 64位,1.1.7 如果我想创建一个包并使用package:CL中的一些符号,我将创建一个像这样的包: (defpackage :foo (:import-from :cl
我正在忙着学习Common Lisp,并且正在寻找一种静态代码分析工具,该工具将帮助我开发更好的样式并避免陷入常见的陷阱。 我找到了Lisp Critic,看起来不错,但我希望有人可以推荐其他一些工具
我正在阅读《Practical Common Lisp》一书,在第 22 章第 284 页的脚注 5 中,我看到一段让我感到困惑的代码片段。 我知道变量list和tail有一个共同的列表结构,但我很困
我正在阅读 Practical Common Lisp ,并且对 Lisp 的 COPY-TREE 函数有疑问。 书中给出了调用的例子 (copy-tree '( '(1 2) '(3 4) '(5
我正在尝试使用 user guide 中的抓取示例运行 geb用于引入依赖项: $ cat my.groovy @Grapes([ @Grab("org.gebish:geb-core:0.9
这里一定有更好的方法,对吧? (format t "Enter your age: ~%") (defun age-case (age) (case age (1 (format t "Y
如何在 do 循环中绑定(bind)从函数返回的多个值? 以下显然是非常错误的,但是这样的事情可能吗? (do (((x y z) (3-val-fn) (3-val-fn))) ((equa
所以我正在学习 Lisp 做分数,这很棒。但是为什么这个相等性检查返回 NIL: * (= 0.2 1/5) NIL ...如果转换为 float 则返回 True第一的: * (=
是否可以“统计”一个文件并找到它的文件类型 - 常规或目录? 最佳答案 阅读关于 portable pathname library 的章节来自 Peter Seibel 的 Practical Co
我是 CL 的新手,正在使用 AllegroCL。我试图弄清楚如何组织我的源代码以满足以下要求: 我想阻止 src 代码包含我的测试套件。 我想以可移植的方式声明项目依赖项(src 和 test de
谁能告诉我最新的标准化 Common Lisp 的文档是什么(应该遵循各种实现的文档)?我问是因为我可以在网上找到很多关于 CL 的书都来自 90 年代,所以我想知道它们是否是最新的。我也来自于在 R
假设我必须定义一个名为foo 的函数。假设,为了定义它,我使用了一些辅助函数 foo1, foo2, foo3, ... 当我加载包含这些函数的文件时,我可以从顶层使用所有这些函数。相反,我只想从顶层
这拒绝编译。注释掉 (setf roll行让它编译。然而,(setf roll...本身在 REPL 中正确评估。 程序: ;; loop n times ; sum up number of hit
我目前正在学习 Common Lisp,并尝试将一些 JSON 发送到网络服务。我要发送的 JSON 以类似于以下的结构表示: ((:ITEMS ((:KEY . "value1") (:IGNO
我有一个带波浪号的目录名(作为字符串):~/projects . 我想得到它的完整路径:/home/user/projects .我怎么做 ? 目标是将它传递给 uiop:run-program ,这
我想从输入文件中读取一个字符串(用户可能修改也可能没有修改)。我想将此字符串视为使用固定数量的参数调用的格式指令。但是,我知道某些格式指令(特别是我想到的 ~/)可能会用于注入(inject)函数调用
我是一名优秀的程序员,十分优秀!