简体   繁体   English

html 表单发送敏感数据 javascript https

[英]html form send sensitive data javascript https

How do I securely send sensitive data like passwords to the server?如何安全地将密码等敏感数据发送到服务器?

Is POST as a method enough? POST 作为一种方法就足够了吗? How do I enable https?如何启用https?

<form method="POST" action="/login">
  Password:
  <input type="password" name="pass">
  <button type="submit">
    Login
  </button>
</form>

Or when using an eventhandler for some button on the page, how do I enable https here:或者当对页面上的某些按钮使用事件处理程序时,如何在此处启用 https:

button.addEventListener("click", function(event) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      // do something
    }
  };
  xhttp.open("POST", "/login", true);
  xhttp.send(<password>);
});

Use SSL or TLS.使用 SSL 或 TLS。

Simply do.简单地做。 There are number of solutions.有多种解决方案。 One of the most well known free solution is https://letsencrypt.org/ which is free.最著名的免费解决方案之一是https://letsencrypt.org/ ,它是免费的。 There are number of tutorial to use this kind of certificate on Apache, Node.js server or any others.有很多教程可以在 Apache、Node.js 服务器或任何其他服务器上使用这种证书。

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

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