再会!
我有 REST API,可以通过 SSL (https://) 访问。我想将正确的证书(或证书链)与我编写的 PHP 和 CURL 脚本一起发出请求。
以下是来自我的目标 ( http://api.vkontakte.ru ) 的证书在 Firefox 中的样子:
http://speedcap.net/img/bc687485819715c65d6fe1e4ca1fdc40/1a2be.png
以下是从 Firefox 保存的“PEM 格式的证书链 X.509”的片段(此处描述:http ://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access- https-ssltls-protected-sites/ ):
-----BEGIN CERTIFICATE-----
MIIFVzCCBD+gAwIBAgIHKx5Ov2FOejANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
[..skip...]
0npsf5fkvT8E13NgVY0PK6V/baMTlTgWXKQZ
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVMx
[..skip...]
qDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZEjYx8WnM25sgVjOuH0aBsXBTWV
U+4=
-----END CERTIFICATE-----
Run Code Online (Sandbox Code Playgroud)
以下是 CURL 初始化的代码示例:
$this->ch = curl_init();
curl_setopt_array($this->ch, array(
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_AUTOREFERER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_SSL_VERIFYPEER => TRUE,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO => <path to my cert>,
));
Run Code Online (Sandbox Code Playgroud)
我收到 CURL 错误 60 …
所以我在 Godaddy 上托管了一个 Wordpress 站点,但 DNS 位于 Route53 上,我希望它只能通过 https 访问。
因此,我使用 ACM 和使用该证书的 Cloudfront 发行版设置了 SSL 证书,但我从 GoDaddy 获得的只是一个 IP 地址,Cloudfront 不允许我将源设置为 IP。
有什么办法可以做到这一点?
wordpress https amazon-web-services amazon-cloudfront amazon-route53
我正在向Geonames Search api发送 ajax 请求。它在 http 协议上运行良好。
但是当我切换到 https(我自己的服务器和 api 请求)时,我的请求被浏览器阻止:Geonames https 证书似乎无效。
我错过了什么?
我正在尝试使用 next 进行 http 到 https 重定向,因此如果用户在http://www.example.com 上进入站点,则重定向到https://www.example.com 我正在使用 GraphQL Yoga服务器端,所以不确定如何在服务器端的索引文件中完成此操作。我已经尝试使用元标记并更改窗口对象中的协议,但在服务器端渲染中没有这样做。有什么方法可以在客户端使用 next js 或在服务器端完成此重定向?
const cookieParser = require('cookie-parser')
const jwt = require('jsonwebtoken')
require('dotenv').config({path: '.env'})
const createServer = require('./createServer')
const db = require('./db')
const sslRedirect = require('heroku-ssl-redirect');
const server = createServer()
//Express middleware to handle cookies
server.express.use(cookieParser())
//decode JWT
server.express.use((req, res, next) => {
const { token } = req.cookies;
if (token) {
const { userId } = jwt.verify(token, process.env.APP_SECRET);
req.userId = userId;
}
next()
})
//Populates user …Run Code Online (Sandbox Code Playgroud) 嘿伙计们,我在 Node JS 和 HTTPS 请求方面有点挣扎。以下代码实际上工作正常,但我不知道如何设置自定义请求标头,如 X-Forwarded-For 和用户代理。有没有办法添加这些?
谢谢 :)
这是我的代码:
const https = require('https');
const options = {
hostname: 'offertoro.com',
port: 443,
path: '/',
method: 'GET'
};
const req = https.request(options, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.on('error', (e) => {
console.error(e);
});
req.end();
Run Code Online (Sandbox Code Playgroud) 当我尝试使用同一服务器(主节点)上的私有 Docker 注册表中的图像在 Kubernetes 中部署应用程序时,收到以下错误:
无法拉取映像“0.0.0.0:5000/continuous-delivery-tutorial:5ec98331a69ec5e6f818583d4506d361ff4de89b-2020-02-12-14-37-03”:rpc des 错误:来自https:// cda 的错误代码 = 未知响应 0.0.0.0:5000/v2/ : http: 服务器向 HTTPS 客户端提供 HTTP 响应
当我打印时,docker system info我可以看到我的注册表是不安全的注册表:
我通过以下命令运行我的注册表:
docker run -d -p 5000:5000 --restart=always --name registry -v $PWD/docker_reg_certs:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key registry:2
Run Code Online (Sandbox Code Playgroud)
谢谢你的任何建议
我有一个 React 应用程序,它使用 .env.production 文件在 HTTPS 上完美运行,其中包含:
HTTPS=true
SSL_CRT_FILE=/etc/ssl/certs/mycert.crt
SSL_KEY_FILE=/etc/ssl/private/mykey.key
Run Code Online (Sandbox Code Playgroud)
package.json 文件包含:
"scripts": {
"start": "env-cmd -f .env.production react-scripts start",
"build:production": "env-cmd -f .env.production react-scripts build"
}
Run Code Online (Sandbox Code Playgroud)
当我做:
npm start
Run Code Online (Sandbox Code Playgroud)
一切正常,我可以从任何地方通过 HTTPS 访问我的服务器。现在,这很有趣,现在我做:
npm run build:production
Run Code Online (Sandbox Code Playgroud)
这也很好用,我得到:
The build folder is ready to be deployed.
You may serve it with a static server:
serve -s build
Run Code Online (Sandbox Code Playgroud)
现在,这是失败的:
1)当我使用上面的serve命令时,.env.production文件中的环境变量没有被拾取!为什么?
2)如果我手动传递环境变量,如下所示:
HTTPS=true SSL_CRT_FILE=/etc/ssl/certs/mycert.crt SSL_KEY_FILE=/etc/ssl/private/mykey.key PORT=8580 serve -s build
Run Code Online (Sandbox Code Playgroud)
似乎只选择了 PORT 变量,但服务器现在在 HTTP 上运行。任何想法为什么?!
我已经配置了 nginx 将请求升级到 https
server {
listen xxx.xxx.xxx.xxx:80;
listen xxx.xxx.xxx.xxx:443 ssl;
server_name example.com www.example.com
access_log /var/log/nginx/www.example.com_access.log;
error_log /var/log/nginx/www.example.com_error.log warn;
ssl_certificate /etc/nginx/ssl/certificates/www.example.com.crt;
ssl_certificate_key /etc/nginx/ssl/certificates/www.example.com.key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
#https://www.scalescale.com/tips/nginx/504-gateway-time-out-using-nginx/
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
proxy_pass https://xxx.xxx.xxx.xxx:8443/;
index index.html ;
}
}
Run Code Online (Sandbox Code Playgroud)
但配置并未将请求升级到 https。
我已经为我的自定义域名 (haydenclay.page) 启用了 HTTPS,但我还需要 Beanstalk url (app-name.elasticbeanstalk.com) 来通过 HTTPS 运行。
HTTPS 目前不起作用,因为证书名称与我的自定义域名匹配,产生:ERR_CERT_COMMON_NAME_INVALID
我需要 HTTPS,因为我发出 API 请求,从 HTTPS 转到 HTTP 会引发混合内容错误。如何在 beanstalk url 上启用 HTTPS?
我已经尝试过像这样在控制台中创建别名
我正在尝试通过 WebDav 协议访问远程服务器,更具体地说是 Perl 的 HTTP::DAV 模块。
根据其文档,与远程目录的耦合以以下方式进行:
use HTTP::DAV;
$d = HTTP::DAV->new();
$url = "http://host.org:8080/dav/";
$d->credentials(
-user => "pcollins",
-pass => "mypass",
-url => $url,
-realm => "DAV Realm"
);
$d->open( -url => $url )
or die("Couldn't open $url: " .$d->message . "\n");
Run Code Online (Sandbox Code Playgroud)
我创建了一个本地 webdav 目录,可以通过http protocol.
根据HTTP::DAV的文档,应该有并且https支持使用该Crypt::SSLeay模块。
该Crypt::SSLeay的机制的文档提供给我们使用内部下面Synopsys的LWP::UserAgent模块,从而提供用于在我们网站资源访问https协议:
use Net::SSL;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new(
ssl_opts => { verify_hostname => 0 },
); …Run Code Online (Sandbox Code Playgroud)