purpleslurple / PurpleSlurple

PurpleSlurple transcodes web pages to make them granularly accessible.
GNU General Public License v2.0
0 stars 0 forks source link

Automatically detect protocol #94

Open purpleslurple opened 10 months ago

purpleslurple commented 10 months ago

// Automatically detect protocol $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; $file_location = $protocol . $_SERVER['HTTP_HOST'] . $file_location;

purpleslurple commented 10 months ago

Add note to documentation about serving over http (e.g. via http://localhost:8000)

In this scenario, when you serve your PHP script over HTTP (not HTTPS), and your PHP script uses $fcontents = @file($theurl); to retrieve a page with the protocol https (e.g., https://www.w3.org/TR/selection-api/), here's how the encryption works:

  1. Client to Server (PHP script to target URL):

    • The request made by your PHP script to https://www.w3.org/TR/selection-api/ will be unencrypted.
    • The URL, query parameters, and other request data will be sent over plain HTTP from your PHP script to the target server (www.w3.org).
  2. Target Server's Response (HTTPS to PHP script):

    • The response from the target server (www.w3.org) to your PHP script will be encrypted.
    • The target server will use HTTPS to send the response back to your PHP script over an encrypted channel.

In this case, the encryption is established between the target server and your PHP script, but not between your PHP script and the server that hosts your PHP script. The request made by your PHP script to the target server (www.w3.org) will be sent over plain HTTP, and the response from the target server back to your PHP script will be encrypted over HTTPS.

However, since your PHP script is not using HTTPS for its own communication, any potential sensitive information in the request (such as query parameters) could be exposed while being transmitted from your PHP script to the target server.

purpleslurple commented 10 months ago

https://chat.openai.com/share/3fddb0ef-6766-40e1-9727-7efb5dc4105c

purpleslurple commented 10 months ago

Need a diagram here. How risky is this really? Also, instructions to set up https/cert?