简体   繁体   English

如何将HTTPS表单提交到HTTPS服务器

[英]How to submit HTTPS forms to a HTTPS server

I need to send a post to another domain featuring HTTPS. 我需要将帖子发送到另一个具有HTTPS的域。 If I send it through normal HTTP, the following browser warning message appears, which will scary users: 如果我通过普通HTTP发送它,则会显示以下浏览器警告消息,这将使用户感到恐惧:

“Although this page is encrypted, the information you have entered is to be sent over an unencrypted connection and could easily be read by a third party. “尽管此页面是加密的,但您输入的信息将通过未加密的连接发送,并且第三方可以轻松读取。 Are you sure you want to continue sending this information?” 您确定要继续发送此信息吗?”

How can I solve this? 我该如何解决?

I can't change all site to HTTPS, is it possible to submit only the POST form using HTTPS? 我无法将所有站点都更改为HTTPS,是否可以使用HTTPS仅提交POST表单?

Can I do it through Javascript/Jquery? 我可以通过Javascript / Jquery做到吗? (if yes, is there an example?) (如果是,是否有示例?)

Thank you 谢谢

The warning is just saying that submitting information from a non-HTTPS site to a site with HTTPS, or vice versa, exposes that information to potential attackers. 警告只是说,从非HTTPS站点向使用HTTPS的站点提交信息(反之亦然)会将信息暴露给潜在的攻击者。

If the page your form is on is using HTTP, change it to HTTPS. 如果您的表单所在的页面正在使用HTTP,请将其更改为HTTPS。 If the page your form is on is using HTTPS and the URL it's submitting to is HTTP then you will have to change the page it is submitting to to HTTPS. 如果您的表单所在的页面正在使用HTTPS,并且其提交到的URL是HTTP,那么您将不得不将其提交到的页面更改为HTTPS。 If the receiving site doesn't support HTTPS then there's no way to avoid this warning, unless you submit it from a non-HTTPS page. 如果接收站点不支持HTTPS,则无法避免此警告,除非您从非HTTPS页面提交。 If the information is sensitive, that is not a good idea. 如果信息敏感,那不是一个好主意。

To change the remote site to use HTTPS, just change the protocol in the URL of your AJAX request. 要将远程站点更改为使用HTTPS,只需更改AJAX请求的URL中的协议。

Maybe this code will do the trick: 也许这段代码可以解决问题:

$("form").each(function (index, form) {
    form.action = form.action.replace("http://", "https://");
});

But it is possible that the warning won't go away. 但是警告可能不会消失。 You could use a text editor and search/replace all action="http:// found in your files to action="https:// . 您可以使用文本编辑器并将文件中找到的所有action="http://搜索/替换为action="https://

Hope it helps. 希望能帮助到你。 Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM