- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经在我的 aws ec2 实例上设置了一个 FTPS 服务器,并使用 vsftpd 配置了 SSL。我使用 -
创建了 SSL 证书sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
我使用 Apache Commons net 连接到我的 FTPS 服务器并使用 - 检索文件
ftps = new FTPSClient(ftpsProtocol, isImplicit);
try
{
int reply;
ftps.connect(server);
System.out.println("Connected to " + server + ".");
// After connection attempt, you should check the reply code to verify
// success.
reply = ftps.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftps.disconnect();
System.err.println("FTP server refused connection.");
}
}
catch (IOException e)
{
if (ftps.isConnected())
{
try
{
ftps.disconnect();
}
catch (IOException f)
{
System.out.println("ERROR!");
// do nothing
}
}
System.err.println("Could not connect to server.");
e.printStackTrace();
System.exit(1);
}
__main:
try
{
ftps.enterLocalPassiveMode();
ftps.setBufferSize(1000);
ftps.execPROT("P");
if (!ftps.login(username, password))
{
ftps.logout();
error = true;
break __main;
}
}
这工作正常,我能够检索文件。既然不是CA证书,Java是如何接受服务器的自签名证书而不抛出错误的呢?
(我的 vsftpd conf 有以下几行 - 我的 vsftpd.conf 有以下几行-
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
ssl_ciphers=HIGH
pasv_enable=YES
pasv_max_port=12100
pasv_min_port=12000
port_enable=YES
)
最佳答案
您没有展示如何初始化您的 FTPSClient
,但我假设您使用了默认值。
查看 latest implementation of FTPSClient
in the trunk of the Subversion repository ,它显然使用了 TrustManager
默认情况下来自 TrustManagerUtils.getValidateServerCertificateTrustManager()
的实现。
反过来,latest implementation of TrustManagerUtils
显示这提供了一个 TrustManager
,它只调用此证书上的 checkValidity
(这是打开验证的选项,甚至不是 ACCEPT_ALL
实现) .不幸的是,checkValidity
仅检查证书在当前时间是否有效,关于其“不早于”和“不晚于”的有效期。它不是针对任何已知信任 anchor 的证书验证。这基本上几乎是无用的,因为能够插入不正确证书的攻击者应该能够创建一个具有他们想要的有效期的证书。
但是,您似乎可以使用 SSLContext
实例化 FTPSClient
,因此使用 new FTPSClient(SSLContext.getDefault())
会给出您使用默认的、更明智的行为(除非您更改了默认的 SSLContext
)。 (当然,您也可以使用具有正确行为的自定义 SSLContext
,但也使用特定的信任库进行初始化。)
我还没有检查其余的实现,但我也想看看它对主机名 validator 做了什么,以防万一。
(可能值得在 Apache Commons Net 项目上报告这一点。这种默认行为当时可能听起来是个好主意,但事实并非如此。)
关于java - Java 如何接受我的自签名证书而无需将其添加到 Java 信任库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33675381/
从今天早上开始,我的证书在 Android 上不再受信任,然后我的应用程序无法再连接: Catch exception while startHandshake: javax.net.ssl.SSL
我想知道是否有人有解决方案允许从usize类型(从访问数组索引或获取矢量长度中获得)的隐式转换为i32?可能吗? 当然,我假设矢量长度和数组范围在i32限制之内。 最佳答案 您可以在函数参数中使用 T
我用 mitmproxy从离开我们网络的出站 AS2 (HTTP) 请求中收集情报。架构是这样的: Mendelson AS2 ➡ mitmproxy ➡ partner AS2 server
我有几个实例,我的 Javascript 代码似乎在泄漏内存,但我不确定我应该从垃圾收集器那里得到什么。 例如 var = new Object() 在 Firefox 中运行的间隔计时器函数似乎会随
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwa
我想我在这里没有想法。 我正在尝试使用具有 ssl 证书的 java 中的 Web 服务。 我创建了一个 keystore 文件,并在其中添加了证书。该文件位于我的项目文件夹中。 我使用以下方式导入它
我在/etc/pki/ca-trust/source/anchors 中添加了一个 crt,这样服务器证书就可以被 ssl 客户端信任。所以,例如,当我 curl https://证书自动受信任。 有
我搜索了很多帖子,但找不到任何解决方案或问题的答案。如何从安装了中间证书的站点下载文件?使用 DownloadManager 时,出现错误“java.security.cert.CertPathVal
我无法使用 SSL: 我从服务器下载了证书,它运行良好。 我还使用本文中的代码将 myCertificate.cert 添加到我的 iPhone 钥匙串(keychain)线程:Importing a
首先,我知道信任所有证书可能存在的风险,但是出于某些测试目的,我必须实现这一点。 如何强制我的客户信任所有证书?我正在使用 javax.websocket 来实现 我所做的只是像连接到 ws 一样 W
信任 $_SERVER['REMOTE_ADDR'] 是否安全?可以通过更改请求的 header 或类似的东西来代替吗? 这样写安全吗? if ($_SERVER['REMOTE_ADDR'] ==
我有一个产品由内部 ASP.NET/MVC 网站组成,所有网站都使用 WIF 通过自定义 STS/IdP 服务启用 SSO。我们现在有一个新的合作伙伴站点托管在我们网络之外的另一个域上,并且希望在用户
我在我开始构建的 Rails 应用程序上使用 sendgrid。我处于测试模式,主要做本地工作,但我发送了很多电子邮件来检查我的流程或电子邮件布局。 我用来接收电子邮件的电子邮件是在 Gmail 上。
我一直在研究我得到的原因: java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: Received fatal al
我有 SVN 服务器通过 HTTPS 在 Apache 下运行 这是我的服务器端配置,“/etc/httpd/conf.d/subversion.conf”: SSLRequireSSL S
我有一个用于开发测试的自签名证书。我已将它添加到证书管理器中的“受信任的根证书颁发机构”文件夹下,当在 IE 或 Chrome 下访问该站点时,它被认为是有效的(在 Firefox 下它不喜欢它是自签
我遇到了 android 4 设备的问题,这些设备在连接到服务器时收到以下异常: java.security.cert.CertPathValidatorException: Trust anchor
我是一个安卓新手。这个问题已经被问过很多次了,但我已经解决了这里几乎所有的问题。 我正在尝试在 Node.Js 服务器(使用 express)和 Android 上的 Volley 上使用自签名证书。
我想使用 WebClient 从安全服务器检索 JSON 文件,但我的 Windows Phone 8 不允许我这样做,因为如果 WebCLient 不信任 SSL 证书,它会抛出异常。 问题在于它不
我正在编写服务器以支持适用于 iOS 和 Android 的基于位置的应用程序。该应用程序要求我们验证用户的身份及其位置。我知道如何做前者,但不知道后者。 是否可以验证客户端发送给我的纬度/经度实际上
我是一名优秀的程序员,十分优秀!