Tag: https

Node.js https pem错误:错误:0906D06C:PEM例程:PEM_read_bio:无起始行

我从证书颁发机构获得了这个文件: domain.com.p7b domain.com.crt domain.com.ca束 我试过这个小代码: var express = require('express'); var app = express(); var fs = require("fs"); var https = require('https'); var privateKey = fs.readFileSync('domain.com.p7b').toString(); var certificate = fs.readFileSync('domain.com.crt').toString(); var ca_bundle = fs.readFileSync('domain.com.ca-bundle').toString(); var credentials = { key: privateKey, ca : ca_bundle, cert: certificate}; https.createServer(credentials,app).listen(8080, function () { console.log('Example app listening on port 8080!'); }); […]

用Node.js创build一个HTTPS服务器

尝试访问我使用NodeJS创build的HTTPS服务器时出现错误。 我该怎么办 : 首先: 生成一个自签名证书 : openssl genrsa -out key.pem openssl req -new -key key.pem -out csr.pem openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem 2.创build简单的NodeJs Https服务器 – var https = require('https'); var fs = require('fs'); var server_port = 8080; var httpsOptions = { key: fs.readFileSync('\key.pem'), cert: fs.readFileSync('\cert.pem') }; var app = […]

NodeJS服务器 – 服务器安全通信

我有两台服务器在同一个域上使用NodeJS。 (server1.example.com和server2.example.com) 我想以安全的方式将消息从一台服务器发送到另一台服务器。 现在,我正在使用通过发送HTTPS POST(例如https://example.com {secret:XXXXX,message:1234}来发送我的消息。 有没有更干净的方法来做到这一点? 如果是这样,那么确切的步骤是什么? 注意:我在网站上有SSLauthentication。 两台服务器都在同一个域中。

如何在nodejs中转发HTTPSstream量?

我使用nodejs来创build一个简单的代理服务器,logginghttp和https请求,但是,我似乎无法得到https请求被logging(http请求是好的) 那么如何在nodejs中创build一个可以build立安全连接的代理服务器呢? 我的代码至今看起来像 var http = require('http'), httpProxy = require('http-proxy'), util = require('util'), url = require('url'); httpProxy.createServer(function (request, response, proxy) { util.log(request.connection.remoteAddress + ": " + request.method + " " + request.url); request.addListener('data', function(chunk) { util.log("request: " + chunk); }); uri = url.parse(request.url); port = 80; if (uri.protocol == 'https:') { // NEVER HAPPENS 🙁 […]

如何通过nodejs中的Web代理使用HTTPS

我可以用HTTP来做到这一点: var http = require ('http'); http.get ({ host: 'my.proxy.com', port: 8080, path: 'http://nodejs.org/' }, function (response) { console.log (response); }); 但是,如果我想要转到HTTPS资源,它不起作用。 我必须使用HTTP连接方法吗? 我将如何构造这个? 谢谢!

Nodejs,通过httpsauthentication并redirect到http

我开发(在node.js)一个简单的网站(例如: http : //www.mydomain.com ),我想让客户端通过https(例如:https: //www.mydomain.com/login )进行身份validation。 成功validation后,他们被redirect到我的网站在http …(不安全) 我怎样才能做到这一点? 我创build了两个简单的文件(mydomain.js和mydomainsecure.js),在两个不同的端口上运行两个节点实例(80代表http,443代表https),但是在https(和redirect到http)上login后,login(显然????) 什么是正确的方法来实现这个?

Node.js中的asynchronoushttps请求

我有一个应用程序,启动https请求到第三方服务执行日志logging。 出于某种原因,我注意到几个小时前,第三方拒绝连接。 但这是一个不同的话题。 我注意到我的node.js应用程序是,尽pipe请求被dynamic创build,因此不应该挂在整个应用程序,他们是。 进程重新启动后,https请求挂起,然后死亡,连接拒绝错误。 示例代码如下。 var logger = function(data){ var req = https.request({ host: 'logs.loggly.com', port: 443, path: '/inputs/<my real key is here, removed obviously>', method: 'POST', headers:{ 'content-type': 'application/json' } }, function(res){ var body = []; res.on('chunk', function(data){ body.push(data); }); res.on('end', function(){ console.log(body.join('')); }) }); req.write(JSON.stringify(data)); req.end(); } 这就是所谓的: logger({ 'test': 'datafoo' }); […]

将http请求redirect到nodejs中的https

我试图redirect我的http页面https,我发现一些讨论已经在那里在stackoverflow 如何强制SSL / https Express.js 。 但是现在http = express.createServer()已经被弃用了。 所以我试图做如下: var http = require("http") , https = require("https"); var app = express(); /* If I use below it gives ECONNREFUSED error */ http.get('*', function(req, res) { var path = req.headers.host; var pos = path.indexOf(':'); res.redirect('https://' + path.substr(0, pos) + ':' + String(app.get('port'))); }); app.get('/', function(req, […]

在监听自定义端口时,使用SSL(https)连接到Nodejs / Socket.IO服务器

我的socket.io服务器正在运行并监听端口6060。 现在,我添加到我的域名SSL证书,以通过https协议服务我的网站。 如果我试图通过http://mydomain.com:6060访问nodejs / socket.io服务器,我得到“欢迎使用socket.io”。 消息,但是当我用https://mydomain.com:6060这是不行的.. 连接到我的socket.io服务器(侦听端口6060)是否可以使用SSL? 在这种情况下我有什么select? 谢谢

nodejs – 更改https服务器证书

我正在使用https代理,并且需要即时更改https证书。 例如: 客户请求www.google.com https服务器(代理)必须使用CommonName = www.google.com创build一个证书 https服务器必须将此证书发送给客户端 https服务器将密钥和证书作为参数,但是我不需要静态证书,我需要在每个不同的请求上更改证书。 有任何想法吗?