- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用最新版本的 nodejs 和 http-proxy 关注在线示例,但是当我的请求发送到端点 https 服务器时出现以下错误:
C:\Users\Me\node_modules\http-proxy\lib\http-proxy\index.js:114
throw err;
Error: DEPTH_ZERO_SELF_SIGNED_CERT
at SecurePair.<anonymous> (tls.js:1370:32)
at SecurePair.EventEmitter.emit (events.js:92:17)
at SecurePair.maybeInitFinished (tls.js:982:10)
at CleartextStream.read [as _read] (tls.js:469:13)
at CleartextStream.Readable.read (_stream_readable.js:320:10)
at EncryptedStream.write [as _write] (tls.js:366:25)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at EncryptedStream.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
我的代码很简单:
var httpProxy = require('http-proxy');
var http = require('http');
var fs = require('fs');
var apimcert = fs.readFileSync('./mycert.pfx');
var proxy = httpProxy.createProxyServer({});
var options = {
pfx: apimcert,
passphrase : 'pAssw0rd',
rejectUnauthorized : 'false',
agent: false
};
var server = require('https').createServer(options, function(req, res) {
console.log("Got a request " + req);
proxy.web(req, res, {
ssl: {
pfx : apimcert,
passphrase : 'pAssw0rd',
rejectUnauthorized : 'false'
//strictSSL: false
},
target: 'https://endpointhost:9443/postev',
secure: true
}
);
});
console.log("listening on port 9442")
server.listen(9442);
如果我设置 secure : false
那么请求会被转发到端点,但显然会返回一个 403 forbidden 响应。我使用的证书和密码来 self 的端点服务器,我已经测试过它们在直接发送请求时确实有效。我想让我的代理做的就是检查请求的内容,为每个请求记录一条消息,然后转发到端点服务器。
我用谷歌搜索了这个问题并尝试摆弄代理和 strictSSL,但无济于事。
最佳答案
我正在使用 Ant design pro
和 umi
。只需将此 secure: false,
添加到 proxy.ts
proxy: {
'/myapi': {
target: 'https://localhost:8443',
changeOrigin: true,
secure: false, // 不进行证书验证
},
umi 会自动刷新配置,刷新浏览器即可。
关于node.js - NodeJS http-代理 : DEPTH_ZERO_SELF_SIGNED_CERT error when proxying https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24887787/
问题 我编写了一个要求客户端证书的最小服务器,但是它始终拒绝与以下authorizationError的连接:DEPTH_ZERO_SELF_SIGNED_CERT。我在下面放置了我遵循的步骤,这些步
当我尝试使用我正在编写的 node.js 客户端连接到网络服务器时出现上述错误。 但是当我尝试连接到服务器时出现错误。 'DEPTH_ZERO_SELF_SIGNED_CERT' 这是发送请求的代码。
我正在使用此 SMTP 设置: secure: true, ignoreTLS : true, port: 465, 但是我收到此错误,并且无法发送电子邮件: [Error: DEPTH_ZERO_S
我正在使用 Node 0.10.26 并尝试通过客户端验证建立 https 连接。 服务器代码: var https = require('https'); var fs = require('fs'
我在同一服务器-客户端微服务的两个不同安装上遇到了两个不同的错误。这些是在不同主机上运行的基于 Node.js 的服务。是的,我使用的是自签名证书。根据在线搜索,我可以在 https.agent 选项
从我的 browserify React 应用程序通过无效 SSL 发出请求时遇到问题,我基本上遇到了这个问题:https://github.com/request/request/issues/41
我正在尝试在 Node 中使用 TLS 设置服务器和一些客户端。我在客户端和服务器上使用自签名证书。服务器运行正常,但是当我尝试连接客户端时,客户端出现以下错误: Error: DEPTH_ZERO_
我的服务器在带有 heroku SSL 插件的 heroku 上运行。服务器是使用以下选项创建的: name: 'ServerName', version: '1.0.0', 我这样运行服务器:
我正在尝试对具有自签名证书的 Web 服务器在 HTTPS 上执行 method=POST。我下载了服务器公共(public)证书并将路径放在发布选项中。但是我在第 47 行收到错误 [Error:
我正在使用最新版本的 nodejs 和 http-proxy 关注在线示例,但是当我的请求发送到端点 https 服务器时出现以下错误: C:\Users\Me\node_modules\http-p
我需要使用 mocha 和 super test 测试通过 HTTPS 提供的 API(证书未过期) 这是服务器的要点: ... var app = express(); var _options =
我是一名优秀的程序员,十分优秀!