我正在创建一个使用HTTPS的基于API的安全web;然而,如果我允许用户配置它(包括发送密码)使用查询字符串这也将是安全的,或者我应该强制它通过POST?


当前回答

是的,您的查询字符串将被加密。

原因是查询字符串是HTTP协议的一部分,HTTP协议是应用层协议,而安全(SSL/TLS)部分来自传输层。首先建立SSL连接,然后将查询参数(属于HTTP协议)发送到服务器。

在建立SSL连接时,您的客户端将按顺序执行以下步骤。假设您正在尝试登录一个名为example.com的站点,并希望使用查询参数发送凭据。您的完整URL可能如下所示:

https://example.com/login?username=alice&password=12345)

Your client (e.g., browser/mobile app) will first resolve your domain name example.com to an IP address (124.21.12.31) using a DNS request. When querying that information, only domain specific information is used, i.e., only example.com will be used. Now, your client will try to connect to the server with the IP address 124.21.12.31 and will attempt to connect to port 443 (SSL service port not the default HTTP port 80). Now, the server at example.com will send its certificates to your client. Your client will verify the certificates and start exchanging a shared secret key for your session. After successfully establishing a secure connection, only then will your query parameters be sent via the secure connection.

因此,您不会暴露敏感数据。但是,使用这种方法通过HTTPS会话发送凭据并不是最好的方法。你应该另辟蹊径。

其他回答

是的,它是。但是对敏感数据使用GET是一个坏主意,原因如下:

主要是HTTP引用泄漏(目标页面中的外部图像可能泄漏密码[1]) 密码将存储在服务器日志中(这显然很糟糕) 浏览器中的历史缓存

因此,即使Querystring是安全的,也不建议通过Querystring传输敏感数据。

虽然我需要注意的是,RFC声明,浏览器不应该发送从HTTPS到HTTP的引用。但这并不意味着糟糕的第三方浏览器工具栏或HTTPS网站的外部图像/flash不会泄露它。

是的,从建立HTTPS连接的那一刻起,一切都是安全的。查询字符串(GET)作为POST通过SSL发送。

是的,只要没人越过你的肩膀看显示器。

From a "sniff the network packet" point of view a GET request is safe, as the browser will first establish the secure connection and then send the request containing the GET parameters. But GET url's will be stored in the users browser history / autocomplete, which is not a good place to store e.g. password data in. Of course this only applies if you take the broader "Webservice" definition that might access the service from a browser, if you access it only from your custom application this should not be a problem.

所以使用post至少密码对话框应该是首选的。另外,正如littlegeek在链接中指出的那样,GET URL更有可能写入你的服务器日志。

是的,您的查询字符串将被加密。

原因是查询字符串是HTTP协议的一部分,HTTP协议是应用层协议,而安全(SSL/TLS)部分来自传输层。首先建立SSL连接,然后将查询参数(属于HTTP协议)发送到服务器。

在建立SSL连接时,您的客户端将按顺序执行以下步骤。假设您正在尝试登录一个名为example.com的站点,并希望使用查询参数发送凭据。您的完整URL可能如下所示:

https://example.com/login?username=alice&password=12345)

Your client (e.g., browser/mobile app) will first resolve your domain name example.com to an IP address (124.21.12.31) using a DNS request. When querying that information, only domain specific information is used, i.e., only example.com will be used. Now, your client will try to connect to the server with the IP address 124.21.12.31 and will attempt to connect to port 443 (SSL service port not the default HTTP port 80). Now, the server at example.com will send its certificates to your client. Your client will verify the certificates and start exchanging a shared secret key for your session. After successfully establishing a secure connection, only then will your query parameters be sent via the secure connection.

因此,您不会暴露敏感数据。但是,使用这种方法通过HTTPS会话发送凭据并不是最好的方法。你应该另辟蹊径。