- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试设置一个使用 HTTPS 的 node.js 服务器。然后我将用 Perl 编写一个脚本来向服务器发出 HTTPS 请求并测量往返的延迟。
这是我的 node.js:
var express = require('express');
var https = require('https');
var fs = require('fs');
var key = fs.readFileSync('encrypt/rootCA.key');
var cert = fs.readFileSync('encrypt/rootCA.pem');
// This line is from the Node.js HTTPS documentation.
var options = {
key: key,
cert: cert
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world - https\n");
}).listen(8088);
key /证书生成如下:
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
这是我的 Perl 脚本:
#!/usr/bin/perl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'https://127.0.0.1:8080');
my $res = $ua->request($req);
if ($res->is_success) {
print $res->as_string;
} else {
print "Failed: ", $res->status_line, "\n";
}
返回错误:
Failed: 500 Can't verify SSL peers without knowing which Certificate Authorities to trust
node.js 文档描述了如何设置 HTTPS 服务器,但对生成主证书和中间证书含糊不清。
https://medium.com/netscape/everything-about-creating-an-https-server-using-node-js-2fc5c48a8d4e
最佳答案
要使 LWP::UserAgent 忽略服务器证书,请使用以下配置:
my $ua = LWP::UserAgent->new;
$ua->ssl_opts(
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
verify_hostname => 0
);
关于node.js - 如何使用 LWP::UserAgent 接受自签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47662461/
我有两台 Windows 10 机器,在其中一台上,我安装了 Strawberry Perl(如果重要,版本 5.30.1)。我的脚本使用的是 REST::Client,在这台机器上,脚本运行完美。
已解决:我通过安装 HTML::HeadParser 修复了它。 但我仍然不知道为什么它突然停止工作。 我注意到一些以前有效的 LWP 请求已经停止工作,所以我制作了一个小脚本来检查原因。 出于某种原
新问题: 我正在使用我的 Perl 脚本执行以下操作: use strict; use warnings; use LWP 5.64; my $browser = LWP::UserAgent->ne
我想发布内容类型为 multipart/form-data 的数据: use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserA
案例一:我的服务器(远程访问没有互联网访问权限)在 443 端口连接到远程服务器。使用 Web 服务 URL,我需要发送 Web 服务请求并接收响应。我能够使用但无法从远程服务器接收响应来发送请求。代
有谁知道在 GET 或 POST 请求中仅获取网页 50% 的最佳方法?我获取的网页需要 10、20 秒才能完全加载,我只需要从页面开头过滤几行。 最佳答案 use 5.010; use strict
我正在使用 LWP 从网页下载内容,我想限制它等待页面的时间。这是在 lwp 中完成的,如下所示: my $ua = LWP::UserAgent->new; $ua->timeout(10); $u
我正在尝试向不可靠的服务器发出请求。这个请求很好,但不是 100% 需要我的 perl 脚本成功完成。问题是服务器偶尔会死锁(我们正在尝试找出原因)并且请求永远不会成功。由于服务器认为它是事件的,它保
我正在使用以下子例程运行 40 个左右的线程: my $app = shift; my $ua = LWP::UserAgent->new(); $ua->timeout(5); my $respon
我正在尝试向 https 服务器发出 LWP 请求。我已获得用户和通行证,建议使用基本身份验证。我尝试了各种代码块,但似乎都出现了身份验证错误。我当前的代码是... use warnings; use
代码如下: $vizFile ='https://docs.recipeinvesting.com/t.aaaf.html'; my $ua = LWP::UserAgent->new; $ua->t
我正在尝试让 LWP 请求对 https 服务器起作用。我已获得用户和通行证,建议使用基本身份验证。我尝试了各种代码块,但似乎都遇到了身份验证错误。我当前的代码是... use warnings; u
代码如下: $vizFile ='https://docs.recipeinvesting.com/t.aaaf.html'; my $ua = LWP::UserAgent->new; $ua->t
我正在尝试使用 LWP::UserAgent 设置凭据,但我无法登录。$username、$passwd 是正确的。我不明白我应该在第三个参数中输入什么(根据dos $realm,这里是Authent
我已经迁移到一个新的托管提供商,具有相同的 freebsd 系统,并且我的一个 perl 脚本停止正常工作。 它从外部 https 站点下载数据并将其存储在 mysql 数据库中。数据采用 cp125
以下脚本在运行 libwww-perl-5.836 的主机上返回综合 header ,但在使用 libwww-perl-6.30.0 的主机上不返回。在这种情况下,脚本会显示以下内容: 500
如何在 perl 中最佳地使用 LWP::UserAgent? 如果我需要进行多次 http 调用,我会重用同一个对象吗? 例如。 my $browser = LWP::UserAgent->new;
Java Thread 对象和 OS 线程(轻量级进程)之间是否存在一对一的映射。也就是说,如果我有一个 Thread 对象,我能否始终准确地识别一个关联的 OS 线程,并且我是否始终具有相同的关联
这句话是否正确:“Linux 中的所有线程都是 LWP 但并非所有 LWP 都是线程”。实际上,我试图了解Linux中的线程实现。 pthread_create 调用 clone 系统调用,但在 ma
my %parameters = ( key => 'value' ); my $response = $ua->ge
我是一名优秀的程序员,十分优秀!