Is an HTTPS query string secure?

前端 未结 9 1459
耶瑟儿~
耶瑟儿~ 2020-11-22 03:52

I am creating a secure web based API that uses HTTPS; however, if I allow the users to configure it (include sending password) using a query string will this also be secure

9条回答
  •  时光取名叫无心
    2020-11-22 04:44

    Yes, your query strings will be encrypted.

    The reason behind is that query strings are part of the HTTP protocol which is an application layer protocol, while the security (SSL/TLS) part comes from the transport layer. The SSL connection is established first and then the query parameters (which belong to the HTTP protocol) are sent to the server.

    When establishing an SSL connection, your client will perform the following steps in order. Suppose you're trying to log in to a site named example.com and want to send your credentials using query parameters. Your complete URL may look like the following:

    https://example.com/login?username=alice&password=12345)
    
    1. 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.
    2. 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).
    3. Now, the server at example.com will send its certificates to your client.
    4. Your client will verify the certificates and start exchanging a shared secret key for your session.
    5. After successfully establishing a secure connection, only then will your query parameters be sent via the secure connection.

    Therefore, you won't expose sensitive data. However, sending your credentials over an HTTPS session using this method is not the best way. You should go for a different approach.

提交回复
热议问题