我只有一个页面,我想强制作为HTTPS页面访问(Apache上的PHP).如何在不使整个目录需要HTTPS的情况下执行此操作?或者,如果您从HTTP页面向HTTPS页面提交表单,它是通过HTTPS而不是HTTP发送的吗?
这是我的例子:
http://www.example.com/some-page.php
Run Code Online (Sandbox Code Playgroud)
我希望它只能通过以下方式访问:
https://www.example.com/some-page.php
Run Code Online (Sandbox Code Playgroud)
当然,我可以把这个页面的所有链接指向HTTPS版本,但这并不能阻止一些傻瓜故意通过HTTP访问它...
我想到的一件事是在PHP文件的标题中放置一个重定向来检查以确保它们正在访问HTTPS版本:
if($_SERVER["SCRIPT_URI"] == "http://www.example.com/some-page.php"){
header('Location: https://www.example.com/some-page.php');
}
Run Code Online (Sandbox Code Playgroud)
但这不是正确的方法,可以吗?
顺便说一句,请不要注意URL.我知道如果它实际上是一个有购物车等的页面,你会以不同的方式做到这一点.您可以将其视为一个网站,该网站以一个价格销售一件商品,您可以在其中输入您的信用卡信息,然后将其提交到外部网站上的支付网关,以便明确向您的卡收费一次.
如果我正在设置服务器并拥有SSL证书,为什么我不会在整个网站上使用HTTPS而不仅仅是购买/登录?我认为加密整个网站并完全保护用户会更有意义.它可以防止诸如决定必须保护什么之类的问题,因为一切都会存在,这对用户来说并不是真正的不便.
如果我已经在网站的一部分使用HTTPS,为什么我不想在整个网站上使用它?
这是一个相关的问题:为什么https仅用于登录?,但答案并不令人满意.答案假设您无法将https应用于整个网站.
我正在尝试使用keytool和openssl应用程序将Java密钥库文件转换为PEM文件.但我找不到转换的好方法.有任何想法吗?
我没有将密钥库直接转换为PEM,而是首先尝试创建PKCS12文件,然后转换为相关的PEM文件和密钥库.但我无法使用它们建立连接.(请注意,我只需要一个PEM文件和一个Keystore文件来实现安全连接.没有像"从一个java密钥库文件开始"这样的限制.:)所以从我的情况可以接受从其他格式开始
但是从jks到pem的直接转换方法是优选的.
可能重复:
URI以两个斜杠开头......它们的行为如何?
绝对URL省略协议(方案),以便将当前页面的一个简写保存
为//用于脚本和链接标记?有人看过/使用过吗?
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
为什么URL以两个正斜杠开头?这是速记http://吗?
我想使用RequireHttpsAttribute来防止将不安全的HTTP请求发送到操作方法.
C#
[RequireHttps] //apply to all actions in controller
public class SomeController
{
[RequireHttps] //apply to this action only
public ActionResult SomeAction()
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
VB
<RequireHttps()> _
Public Class SomeController
<RequireHttps()> _
Public Function SomeAction() As ActionResult
...
End Function
End Class
Run Code Online (Sandbox Code Playgroud)
不幸的是,ASP.NET Development Server不支持HTTPS.
如何在发布到生产环境时使我的ASP.NET MVC应用程序使用RequireHttps,而不是在ASP.NET Development Server上的开发工作站上运行时?
我知道,关于这个问题有很多不同的问题和很多答案...但我无法理解......
我有:ubuntu-9.10-desktop-amd64 + NetBeans6.7.1从"关闭"安装.代表.我需要通过HTTPS连接到某个站点.为此我使用Apache的HttpClient.
从教程我读到:
"一旦正确安装了JSSE,通过SSL进行安全的HTTP通信
就像普通的HTTP通信一样简单." 还有一些例子:
HttpClient httpclient = new HttpClient();
GetMethod httpget = new GetMethod("https://www.verisign.com/");
try {
httpclient.executeMethod(httpget);
System.out.println(httpget.getStatusLine());
} finally {
httpget.releaseConnection();
}
Run Code Online (Sandbox Code Playgroud)
到现在为止,我写道:
HttpClient client = new HttpClient();
HttpMethod get = new GetMethod("https://mms.nw.ru");
//get.setDoAuthentication(true);
try {
int status = client.executeMethod(get);
System.out.println(status);
BufferedInputStream is = new BufferedInputStream(get.getResponseBodyAsStream());
int r=0;byte[] buf = new byte[10];
while((r = is.read(buf)) > 0) {
System.out.write(buf,0,r);
}
} catch(Exception ex) {
ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
结果我有一组错误:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable …Run Code Online (Sandbox Code Playgroud) 从命令行(通过https,而不是ssh)启动推送或任何其他操作,调用用户名和密码不仅会失败,但是当它发生时,它会返回
Username for 'https://github.com': username
Password for 'https://username@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/username/repository.git/'
Run Code Online (Sandbox Code Playgroud)
我没有@github.com地址.密码和用户名是正确的.
我知道我可以切换到SSH并使用密钥,但这并不能解决验证失败的原因.
我一直在做很多研究,但找不到办法解决这个问题.我正在尝试从https服务器执行jQuery ajax调用到运行带有自定义自签名证书的jetty的locahost https服务器.我的问题是我无法确定响应是拒绝连接还是不安全响应(由于缺少证书接受).有没有办法确定两种情景之间的差异?的responseText,并且statusCode总是在这两种情况下是相同的,即使在Chrome控制台我可以看到一个区别:
net::ERR_INSECURE_RESPONSE
net::ERR_CONNECTION_REFUSED
Run Code Online (Sandbox Code Playgroud)
responseText总是""并且statusCode对于两种情况总是"0".
我的问题是,如何确定jQuery ajax调用是否因为ERR_INSECURE_RESPONSE或由于ERR_CONNECTION_REFUSED?而失败?
一旦证书被接受,一切正常,但我想知道本地主机服务器是关闭,还是启动并运行,但证书尚未被接受.
$.ajax({
type: 'GET',
url: "https://localhost/custom/server/",
dataType: "json",
async: true,
success: function (response) {
//do something
},
error: function (xhr, textStatus, errorThrown) {
console.log(xhr, textStatus, errorThrown); //always the same for refused and insecure responses.
}
});
Run Code Online (Sandbox Code Playgroud)

即使手动执行请求,我也会得到相同的结果:
var request = new XMLHttpRequest();
request.open('GET', "https://localhost/custom/server/", true);
request.onload = function () {
console.log(request.responseText);
};
request.onerror = function () {
console.log(request.responseText);
};
request.send();
Run Code Online (Sandbox Code Playgroud) https ×10
ssl ×4
java ×2
ajax ×1
apache ×1
asp.net-mvc ×1
cors ×1
encryption ×1
git ×1
github ×1
html ×1
html5 ×1
http ×1
http-get ×1
iis-express ×1
javascript ×1
jquery ×1
openssl ×1
php ×1
relative-url ×1
security ×1