除了使用浏览器之外,如何获取使用 https 协议的网站的公钥?还有其他方法吗?就像从终端一样。
更新 - 我想要所有的方法,以便我可以选择最适合我的方法
我们的团队会抓取网站以使我们的信息保持最新。我在抓取 HTTPS 页面时遇到了安全异常。问题在于 Java 在接受页面自签名证书时存在问题。
我没有保留要接受的证书列表(这在将来可能很难维护),而是使用 neu242 提供的解决方法来禁用 SSL 证书验证。
public static void disableCertificateValidation()
{
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
{
// TODO Auto-generated method stub
}
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException
{
// TODO Auto-generated method stub
}
}}; …Run Code Online (Sandbox Code Playgroud) 我在 Windows 7 x64 上使用 Requests 1.2.3,并尝试通过将参数传递proxies给请求,使用 HTTPS 代理通过 HTTPS 连接到(任何)站点。
urllib2我在使用's时没有遇到此错误ProxyHandler,所以我认为它不在我的代理这边。
>>> opener = urllib2.build_opener(urllib2.ProxyHandler({'https': 'IP:PORT'}))
>>> resp = opener.open('https://www.google.com')
>>> resp.url
'https://www.google.co.uk/'
>>> resp = requests.get('https://www.google.com', proxies={'https': 'IP:PORT'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\requests\api.py", line 55, in get
return request('get', url, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 335, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 438, …Run Code Online (Sandbox Code Playgroud) 我发现了 2 个不同的代码片段可以在我的网站上强制使用 https:
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
Run Code Online (Sandbox Code Playgroud)
和
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Run Code Online (Sandbox Code Playgroud)
我确信它们都可以工作(一个来自 Httpd Wiki,另一个来自 SSL shopper)。有人能够解释他们如何执行重定向的差异吗?
我刚刚开始使用 CloudFlare“灵活 SSL”,这允许用户在连接到我的服务器时拥有 SSL(当然是通过 CloudFlare)。
\n\n请求的流程如下:
\n\n访客<-- SSL --> CloudFlare <-- 非 SSL -->我的服务器(Nginx w/pagespeed)
\n\n当 Nginx 重写我的资源(css、js、jpegs 等)时,问题就出现了,nginx 总是收到来自 CloudFlare 的 http 请求,所以显然 Nginx 将资源返回为 http(在 html 中),当用户尝试加载它们时,他们会得到浏览器上有一个丑陋的图标,警告不安全的内容,或者根本不加载不安全的内容,从而完全破坏页面。
\n\n这些是我当前正在使用的过滤器:pagespeed EnableFilters move_css_above_scripts,move_css_to_head,rewrite_style_attributes,combine_javascript,insert_image_dimensions,collapse_whitespace,sprite_images,ins\xe2\x80\x8c\xe2\x80\x8bert_dns_prefetch;
那么如何让 nginx pagespeed 以 https 形式返回资源呢?当请求是http时,如何作为非https?
\n\n谢谢。
\n在我的app/config/security.yml文件中有:
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- { path: ^/admin, roles: ROLE_ADMIN, requires_channel: https }
Run Code Online (Sandbox Code Playgroud)
在开发中(使用内置服务器的 symfony),如果我访问localhost/login它,它会将我重定向到https://localhost/login.
但是,在我的生产站点中,example.com/login我只看到登录页面。浏览器指示连接不安全。
我的直觉认为这可能与 nginx 配置文件有关。
server {
listen 80;
listen 443 ssl;
server_name example.com;
root /var/www/symfony/web;
client_max_body_size 500M;
location / {
# try to serve file directly, fallback to app.php
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info …Run Code Online (Sandbox Code Playgroud) 我尝试从 Github 下载 7zip 文件,但没有成功,代码如下:
var fs = require('fs');
var https = require('https');
options = {
host : "github.com",
port : 443,
path : "/msysgit/msysgit/releases/download/Git-1.9.5-preview20150319/PortableGit-1.9.5-preview20150319.7z",
method : 'GET',
rejectUnauthorized : false,
requestCert : true,
agent : false
};
var file = fs.createWriteStream("installer.7z");
var request = https.get(options, function(response){
response.pipe(file);
file.on("finish", function(){
file.close();
});
});
request.end();
request.on('error', function(err){
throw (err);
});
Run Code Online (Sandbox Code Playgroud)
此代码不会从 Github 下载文件,但如果我更改下载 Notepad++ 的选项:
options = {
host : "notepad-plus-plus.org",
port : 443,
path : "/repository/6.x/6.8/npp.6.8.bin.7z",
method : 'GET',
rejectUnauthorized …Run Code Online (Sandbox Code Playgroud) 我使用resty.http模块。但数据是被使用的。对于通常的 http 或 https,无需验证即可正常工作。
local http = require("resty.http").new()
local res, err = http:request_uri(url, {
method = method,
headers = headers,
body = body,
ssl_verify = false
})
Run Code Online (Sandbox Code Playgroud)
但如果我不使用ssl_verify它就不会出现错误:
lua ssl证书验证错误:(20:无法获取本地颁发者证书),
我发现使用 Googlelua_ssl_trusted_certificate可以提供帮助。但我不知道它有什么帮助。我已经测试过这样的命令:lua_ssl_trusted_certificate /etc/ssl/certs/GlobalSign_Root_CA.pem;但它对我没有帮助。
如何正确验证https?
我在 openSUSE 上使用 Git,并在尝试通过 HTTPS 克隆 Git 存储库时收到以下错误。
$ git clone https://example.com/foo.git
Cloning into 'foo'...
fatal: unable to access 'https://example.com/foo.git/': SSL certificate problem: unable to get local issuer certificate
Run Code Online (Sandbox Code Playgroud)
我该如何解决?我是一名 openSUSE 新手,但了解其他 Linux 发行版。
我正在尝试在我的项目中使用内联脚本,但我不断收到此错误:“拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script-src 'self'”。'unsafe-inline' 关键字、哈希值 ('sha256-hyQXPyDjuL7UGCz8hPIbJ2ZzKwE8uqNzvUJB9/9T6jc=') 或随机数 ('nonce-...') 都需要启用内联执行。
我在这里查看了一堆其他类似的问题,他们都说这与元标记有关并包含以下内容:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
但这并没有什么区别,我已经从我的中删除了所有元标记<head> ,但仍然出现相同的错误。这个问题可能来自
<head> 哪里?我用 express-generator 创建了我的项目,但我在我的任何文件中都找不到任何 CSP。
我完全不知道是什么阻止了内联脚本,如果我能提供任何代码,请告诉我,但我不知道是什么原因造成的,我不知道要提供什么代码