标签: https

知道服务器是通过HTTP还是HTTPS访问的最佳方法是什么?

使用Apache和PHP,了解它的最佳方法是什么,并强制使用HTTPS?

我在phpinFO()中搜索$ _SERVER变量,发现没什么可以帮助的.

编辑:感谢您的答案和建议!我无法在服务器级别强制它,因为它仅用于登录页面.

php apache https apache2

0
推荐指数
1
解决办法
100
查看次数

如何使用PHP检测安全连接(https)?

目前我的服务器上已包含SSL.想通过https强制我的用户使用登录页面登录.

<?php

  if (empty($_SERVER['https']) || $_SERVER['https'] != 'on') {
    header('location: https://my_login_page');
    exit();
    }

  # rest of code
  ...
Run Code Online (Sandbox Code Playgroud)

但是当没有SSL时,这是一个问题.

现在我有情况.用户请求关注URL

http://domain.com/login.php
Run Code Online (Sandbox Code Playgroud)

在这里,我无法访问$_SERVER['https']并希望确保可以将用户重定向到

https://domain.com/login.php
Run Code Online (Sandbox Code Playgroud)

例如,SSL证书在一段时间后过期,并希望保持用户使用登录w/out安全连接.

我的目标是这样的例子:

if (ssl_installed() && (empty($_SERVER['https']) || $_SERVER[] != 'on')) {
  header('location: https://domain.com/login.php');
  exit();
  }

# when there's no SSL it continues using HTTP
Run Code Online (Sandbox Code Playgroud)

是的,想写函数(例如ssl_installed():),true当可能使用安全连接时返回,否则false.

我已经尝试过使用get_headers()并意识到它总是会对https://链接返回false .

可能的方法:

我已经有了解决方案.我的数据库中的配置表包含行ssl=1(或0),并且在建立数据库连接后我使用此值来判断是否可以使用SSL,并且上面提到的函数使用此值返回结果.

我的问题是:有更简单的解决方案吗?

要明确:我正在寻找PHP-ONLY SOLUTION(自动检测)!

任何帮助,将不胜感激.

php security ssl https

0
推荐指数
1
解决办法
8397
查看次数

安全地发送没有https的PHP表单?

我是网站安全新手,我需要建立一个注册和登录系统.我还没有使用https,如何才能确保我的注册安全?

这是我的注册表单index.php,我使用ajax将表单值传递给create_account.php.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
function submitForm() {
    $.ajax({type:'POST', url: 'create_account.php', data:$('#ContactForm').serialize(), success: function(response) {
        $('#ContactForm').find('.form_result').html(response);
    }});

    return false;
}

</script>
<form id="ContactForm" onsubmit="return submitForm();" method="POST">
   <input type="text" name="fname" value=""/> 
   <input type="text" name="lname" value="" />
   <input type="text" name="email" value="" />
   <input type="text" name="vEmail" value="" /> 
   <input type="password" name="password" value="" />
   <input type="password" name="vPassword" value="" />
   <input type="submit" name="submit" value="Submit" onclick="password.value=sha256_hash(password.value)"/>
<div class="form_result"> 
Run Code Online (Sandbox Code Playgroud)

我试过onclick ="password.value = sha256_hash(password.value)"但它根本不起作用.现在我不确定攻击者如何获取从index.php发送到create_account.php的信息.是否可以哈希(sha256/512)并用javascript加盐?在create_account.php中,我已经在做这种类型的安全性了.

如果不可能,我们如何设置https(我对ssl几乎一无所知)?

php forms security hash https

0
推荐指数
1
解决办法
404
查看次数

IP地址上的Node.js HTTPS POST请求失败

我正在尝试使用以下脚本创建HTTPS POST SOAP请求:

var http = require('http');

function Authenticate() {
  // Build the post string from an object
  var post_data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:typ=\"http://company.com/mse/types\"><soapenv:Header/><soapenv:Body><typ:Login><typ:Credential userName=\"username\" password=\"password\"/></typ:Login></soapenv:Body></soapenv:Envelope>";
  // An object of options to indicate where to post to

  var post_options = {
    port: 443,
    host: 'https://132.33.223.33', //MSE12
    path: '/aaa/',
    method: 'POST',

    headers: {
        'Content-Type': 'text/xml;charset=UTF-8',
        'SOAPAction': '\"Login\"',
        'Accept-Encoding': 'gzip,deflate',
        'Host':'173.37.206.33',
        'Connection':'Keep-Alive',
        'User-Agent':'Apache-HttpClient/4.1.1 (java 1.5)'
    }
  };

  // Set up the request
  var post_req = http.request(post_options, function(res) {
      res.setEncoding('utf8');
      res.on('data', …
Run Code Online (Sandbox Code Playgroud)

https http http-post node.js

0
推荐指数
1
解决办法
3902
查看次数

什么是ssl证书中的数据加密

有人可以指点我理解ssl证书的"密钥使用"属性的好文章吗?使用"数据加密"作为其中一个值获得证书的利弊是什么?

这是推荐的吗?最近,我们必须在我们的网站上托管一个Web服务,供第三方使用,其中一个要求是证书必须在"密钥使用"中具有"数据加密".目前我们的网站已经有ssl,但密钥用法没有'数据加密'.

如果我们购买带有数据加密的新证书并用新的证书替换当前的站点证书,会不会有明显的缓慢?

ssl https ssl-certificate

0
推荐指数
1
解决办法
8699
查看次数

与HTTPS失去联系

我正在编写一个需要处理丢失连接的Web客户端.

如果使用HTTPS和Internet连接断开连接到服务器,服务器是否会丢失会话信息?

恢复Internet连接后,客户端是否需要重新登录服务器,还是依赖于服务器?

https session

0
推荐指数
1
解决办法
950
查看次数

SSL安装后,某些脚本停止工作

我使用以下代码打印div元素内的内容.这对我来说很好,直到我在我的服务器中安装了SSL证书.如果我通过访问页面,代码仍然有效http://.但是,通过访问同一页面时它无法正常工作https://.我需要帮助解决这个问题.

function PrintElem(elem)
{
    Popup($(elem).html());
}

function Popup(data) 
{
    var mywindow = window.open('', 'Business Sense Chart', 'height=600,width=1200');
    mywindow.document.write('<html><head><title>Business Sense Analytics</title>'); 
    mywindow.document.write('<link rel="stylesheet" href="./css/style.css" type="text/css" />');
    mywindow.document.write('</head><body><center>');
    mywindow.document.write(data);
    mywindow.document.write('</center></body></html>');
    mywindow.print();
    return true;
}
Run Code Online (Sandbox Code Playgroud)

注意:当我使用firebug诊断错误时,它显示错误"$不是函数".类似的其他脚本也面临同样的问题.

javascript ssl https jquery

0
推荐指数
1
解决办法
4856
查看次数

如何在JAVA中保存来自HTTPS网址的文件?

我正在尝试使用outputstream从URL保存文件.该URL由https保护.所以当我尝试获取以下文件时出现了一些错误

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at java.net.URL.openStream(Unknown Source) 
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
    at java.security.cert.CertPathBuilder.build(Unknown Source)
    ... 60 more
Run Code Online (Sandbox Code Playgroud)

假设我想从这个URL打开文件

https://www.filepicker.io/api/file/KW9EJhYtS6y48Whm2S6D?signature=4098f262b9dba23e4766ce127353aaf4f37fde0fd726d164d944e031fd862c18&policy=eyJoYW5kbGUiOiJLVzlFSmhZdFM2eTQ4V2htMlM2RCIsImV4cGlyeSI6MTUwODE0MTUwNH0=
Run Code Online (Sandbox Code Playgroud)

所以我做了类似的事情:

try{    
    URL URL = new URL('https://www.filepicker.io/api/file/KW9EJhYtS6y48Whm2S6D?signature=4098f262b9dba23e4766ce127353aaf4f37fde0fd726d164d944e031fd862c18&policy=eyJoYW5kbGUiOiJLVzlFSmhZdFM2eTQ4V2htMlM2RCIsImV4cGlyeSI6MTUwODE0MTUwNH0=');
    String = path = "D://download/";
    InputStream ins = url.openStream();
    OutputStream ous = …
Run Code Online (Sandbox Code Playgroud)

java https outputstream httpurlconnection filepicker.io

0
推荐指数
1
解决办法
6284
查看次数

Android将发布数据发送到webservice

嗨,我正在尝试将数据发送到Web服务

String url =" https://www.myurl.com ";

    URL urlobj =  new URL(url);
    HttpsURLConnection con = (HttpsURLConnection) urlobj.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    String urlParameters = GenerateUrlParameters(data);

    con.setDoOutput(true);
    con.setDoInput(true);

    Log.i("test", "hit1");

    DataOutputStream  wr = new DataOutputStream(con.getOutputStream());

    Log.i("test", "hit2");

    wr.writeBytes(urlParameters);

    wr.flush();
    wr.close();
Run Code Online (Sandbox Code Playgroud)

Hit1被击中,但它在下一行失败并且没有击中hit2.我究竟做错了什么 ?

我的logcat

10-18 09:17:33.302: D/gralloc_goldfish(2228): Emulator without GPU emulation detected.
10-18 09:17:33.322: W/TextLayoutCache(2228): computeValuesWithHarfbuzz -- need to force to single run
10-18 09:17:37.862: I/test(2228): hit1
10-18 09:17:37.872: D/AndroidRuntime(2228): Shutting down VM
10-18 09:17:37.872: W/dalvikvm(2228): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
10-18 …
Run Code Online (Sandbox Code Playgroud)

java https android web-services

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

在php5中使用https

问题:如何在注册/登录(任何其他)php页面中使用https?伪代码:

is it https?
yes continue
no redirect same page via https
Run Code Online (Sandbox Code Playgroud)

背景: 我想做一个安全的注册和登录表格.我想通过所有步骤来检测我是否错过了什么.2.我想特别询问如何使用https来保护去往服务器的密码.

  • 添加1.步骤:a.用户点击链接注册/登录=>检查注册/页面是否使用https - 如果不是redirct并使用https(这我做了一些但不知道怎么做 - 问题的第二部分)b.所以现在我通过https连接到注册/登录页面,用户将密码设置为imput fieldt,显然设置为输入类型密码(显然使用post方法),然后
    按下提交按钮 - 因为我使用post + https数据应该安全地传递给服务器.C.现在注册/登录脚本被传递,并且它被重定向到句柄页面它可能是相同的php页面 - 我还应该使用https.d.现在我通过sha256输入密码,比如sha256(sha256(密码)+ salt),
    使用预准备语句建立与数据库的连接以防止sql注入e.如果输入数据是好的注册完成(一些邮件可以发送,但它的另一个问题,这里不需要解决),如果它是登录和密码适合我把一些数据到会话 - 关于用户的信息,如id +权利,问题是:我还应该使用https作为会员部分吗?我认为这并不重要,除非我想更改密码(我将再次使用https更改
    密码表单).
  • 添加2. HTTPS CONNECTION CHECK用户单击链接到登录/注册页面,我应该这样做:

    是HTTPS吗?是=> CONTINUE,NO =>通过HTTPS重定向页面我知道有一些变量或某些东西告诉我它是否是https,但我不知道如何在php5中编写它(这一两行).那么问题是如何做第2点(HTTPS连接CHECK)?

php mysql https login

0
推荐指数
1
解决办法
225
查看次数