标签: https

如何使用 Express 侦听端口 443?

var app, certificate, credentials, express, fs, http, httpServer, https, httpsServer, privateKey;

fs = require('fs');

http = require('http');

https = require('https');

privateKey = fs.readFileSync('key.pem', 'utf8');

console.log(privateKey);

certificate = fs.readFileSync('cert.pem', 'utf8');

console.log(certificate);

credentials = {
  key: privateKey,
  cert: certificate
};

express = require('express');

app = express();

httpServer = http.createServer(app);

httpsServer = https.createServer(credentials, app);

httpServer.listen(80);

httpsServer.listen(443);
Run Code Online (Sandbox Code Playgroud)

我在 OS X 上,我确认没有其他东西在 80 和 443 上收听。我在运行sudo时运行http://127.0.0.1它,它可以工作。但是,当我去时https://127.0.0.1,我没有找到。

我做错了什么?

https node.js express

2
推荐指数
2
解决办法
7547
查看次数

可以使用 apache 跨 nodejs 服务器进行负载平衡

是否可以使用 apache 在一组 nodejs 服务器之间进行负载平衡?我还需要使用证书配置 apache 以提供 ssl 并且只提供 https 请求。

简单的设置是 2 个 apache 服务器,它们将成为我的负载平衡器。所有请求都将通过 https 进入这两个负载均衡器之一。

从那里负载平衡器需要确定将请求路由到哪个服务器。这将是运行相同节点进程的 6 台服务器之一。

我知道有 mod_cluster,但我只在 JBoss 设置中使用过它,并不确定这是否适用于 nodejs 服务器。

我也意识到这可能不是最好的设置,因为节点是单线程的,我可以尝试像节点集群这样的东西。然而,节点集群似乎是垂直扩展而不是水平扩展。

我也知道有 nginx 和 haproxy,尽管我从未使用过它们中的任何一个,并且对 apache 有更多的经验。也不确定 haproxy 和 nginx 是否支持只允许使用证书的 ssl 连接。

这种类型的负载平衡是否可以使用 apache,如果可以,如何实现?

apache ssl https load-balancing node.js

2
推荐指数
1
解决办法
2477
查看次数

Getting "SSLPeerUnverifiedException" from Amazon SNS when using HTTPS endpoint

I'm having trouble getting Amazon SNS to send a subscription message to my HTTPS endpoint. The CloudWatch logs report the following:

{
    "delivery": {
        "deliveryId": "7bdda6a5-0000-5d6d-b0c0-e9b254fde521",
        "destination": "https://www.beta.yogacentre.com/webhooks/sns",
        "providerResponse": "SSLPeerUnverifiedException in HttpClient",
        "dwellTimeMs": 63661,
        "attempts": 4
    },
    "status": "FAILURE"
}
Run Code Online (Sandbox Code Playgroud)

It looks like it doesn't like the SSL certificate I'm using, but I confirmed that the root CA is on the list SNS checks. Chrome reports my connection uses TLS 1.2, so it should be compatible with the recent end …

ssl https amazon-web-services amazon-sns tls1.2

2
推荐指数
1
解决办法
632
查看次数

使用 AWS Route 53 http 重定向工作,https 超时

使用此处提到的路由规则:在 Amazon Route53 中设置基于 DNS 的 URL 转发

<RoutingRules>
    <RoutingRule>
        <Redirect>
            <Protocol>https</Protocol>
            <HostName>dota2.becomethegamer.com</HostName>
            <HttpRedirectCode>301</HttpRedirectCode>
        </Redirect>
    </RoutingRule>
</RoutingRules>
Run Code Online (Sandbox Code Playgroud)

我能够看到http://becomethegamer.com正确重定向到https://dota2.becomethegamer.com但https://becomethegamer.com超时。

我以为是那Protocol件作品,但意识到那是出站而不是入站。

这是在一个 bucked 命名中becomethegamer.com,在 Route 53 中becomethegamer.com是一个别名,目标是该存储桶。

什么可能导致 https 无法重定向?

dns https routing amazon-route53

2
推荐指数
1
解决办法
1025
查看次数

使用 C# 从控制台应用程序访问 HTTPS URL

我希望我的应用程序访问指定的 HTTPS URL 并从该 URL 下载 CSV 文件。

我有以下代码:

程序.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Security;
using System.IO;

namespace httpWebRequest_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var webAddr = "https://SFTP URL/xyz.csv";
            var httpWebRequest = (HttpWebRequest) WebRequest.Create(webAddr);
            httpWebRequest.ContentType = "text/csv";
            httpWebRequest.Method = "POST";
            var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
            //ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
            Stream resStream = httpResponse.GetResponseStream();
        }

        AcceptAllCertification aac = new AcceptAllCertification();

        public static RemoteCertificateValidationCallback …
Run Code Online (Sandbox Code Playgroud)

c# url ssl https

2
推荐指数
1
解决办法
5621
查看次数

端口 443 有效但 https 无效

我有一个网站设置,如果我加载网站http://www.url.com:443并按预期工作,但如果我加载,https://www.url.com我会在 Chrome 上收到“ERR_CONNECTION_CLOSED”错误。

我已经设置了 iptables 来通过端口 80 和 443 加载端口 3000。

服务器运行centos,现阶段没有ssl证书设置

ssl https

2
推荐指数
1
解决办法
6496
查看次数

在金字塔中通过 https 提供静态文件

我想通过 request.static_url('some_file') 在金字塔中提供静态文件。由于多项服务,我的模板有如下几行:

<script type="text/javascript" src="${request.static_url('dbas:static/first')}"></script>
<script type="text/javascript" src="${request.static_url('websocket:static/second')}"></script>
Run Code Online (Sandbox Code Playgroud)

但不幸的是,方法 static_url() 只提供带有http作为 url_scheme 的链接,但我想要https。我怎样才能做到这一点?

谢谢!

https static http url-scheme pyramid

2
推荐指数
1
解决办法
922
查看次数

Instagram OAuthException :您必须提供 client_id

我一直在尝试在我的 Web 应用程序中使用 Instagram API 的服务器端身份验证。我已经按照Intagram's API Page提供的步骤操作,但我不断收到错误消息you must provide a client_id。代码写在 node/express.js 中。这是我的代码。
PS:请不要建议我使用 istagram-node API。

索引.js

var bodyParser = require('body-parser');
var express = require('express');
var app = express();
var https = require('https');
var session = require('express-session');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(express.static(__dirname+'/public'));
app.use(session({
  secret: process.env.SECRET,
  resave: true,
  saveUninitialized: false
}))

app.set('port',process.env.PORT);

app.get('/',function(req,res){
  res.render('index')
});

app.get('/home',function(req,res){
  req.session.code = req.query.code;
  var data = JSON.stringify({
      client_id: process.env.CLIENT_ID,
      client_secret: process.env.CLIENT_SECRET,
      grant_type: "authorizaton_code",
      redirect_uri: "...",
      code: req.session.code
  })
  var options = { …
Run Code Online (Sandbox Code Playgroud)

javascript https node.js express instagram-api

2
推荐指数
1
解决办法
1483
查看次数

如何使用java访问github graphql API

我需要访问github graphql API以获取有关某个存储库的一些数据。以下curl命令工作正常

curl -i -H "Authorization: bearer myGithubToken" -X POST -d '{"query": "query { repository(owner: \"wso2-extensions\", name: \"identity-inbound-auth-oauth\") { object(expression:\"83253ce50f189db30c54f13afa5d99021e2d7ece\") { ... on Commit { blame(path: \"components/org.wso2.carbon.identity.oauth.endpoint/src/main/java/org/wso2/carbon/identity/oauth/endpoint/authz/OAuth2AuthzEndpoint.java\") { ranges { startingLine endingLine age commit { message url history(first: 2) { edges { node {  message url } } } author { name email } } } } } } } }"}' https://api.github.com/graphql
Run Code Online (Sandbox Code Playgroud)

现在我需要调用与Java操作输出相同的方法。这是我尝试过的代码,

  public void callGraphqlApi(){
    CloseableHttpClient httpClientForGraphql = null;
    CloseableHttpResponse httpResponseFromGraphql= null; …
Run Code Online (Sandbox Code Playgroud)

java https post github graphql

2
推荐指数
1
解决办法
5348
查看次数

nodeJS - 发出 HTTPS 请求,发送 JSON 数据

我想将 HTTPS POST 从一个 nodeJS 服务器发送到另一个。我有一些 JSON 数据要随此请求发送(由 html 表单填充)。

我怎样才能做到这一点?我知道 https.request() 但似乎没有将 JSON 作为查询的一部分包含在内的选项。根据我的研究,HTTP 请求似乎可以,但 HTTPS 请求不行。我该如何解决这个问题?

const pug = require('pug');
var cloudinary = require('cloudinary');
var express = require('express');
var multer = require('multer');
var upload = multer({ dest: 'uploads/' });
var request = require('request');
var bodyParser = require('body-parser');

var options = {
 hostname: 'ec2-54-202-139-197.us-west-2.compute.amazonaws.com',
 port: 443,
 path: '/',
 method: 'GET'
};

var app = express();
var parser = bodyParser.raw();
app.use(parser);

app.set('view engine', 'pug');

app.get('/', upload.single('avatar'), function(req, res) {
 return …
Run Code Online (Sandbox Code Playgroud)

https json node.js

2
推荐指数
1
解决办法
1万
查看次数