Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active November 2, 2023 10:01
Show Gist options
  • Select an option

  • Save unitycoder/ec217d20eecc2dfaf8d316acd8c3c5c5 to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/ec217d20eecc2dfaf8d316acd8c3c5c5 to your computer and use it in GitHub Desktop.

Revisions

  1. unitycoder revised this gist Nov 2, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ foreach ($cert in $certs) {
    - Open firewall port for incoming TCP 4443 (if you want other computers from LAN to connect into your webserver)

    ### UNINSTALLING
    - netsh http delete sslcert ipport=0.0.0.0:4443
    - **CommandPrompt** (as administrator): ```netsh http delete sslcert ipport=0.0.0.0:4443```

    ### TROUBLESHOOTING
    > "SSL Certificate add failed, Error: 1312 A specified logon session does not exist. It may already have been terminated."
  2. unitycoder revised this gist Nov 2, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ### Using HTTPListener with HTTPS
    - **VS**: c# httplistener project, add listener.Prefixes.Add($"https://192.168.1.xxx:4443/"); *or some other ip/port
    - **VS**: c# httplistener project, add ```listener.Prefixes.Add($"https://192.168.1.xxx:4443/");``` *or some other ip/port
    - **Browser**: Test connecting into it, error: "Secure Connection Failed : Error code: PR_CONNECT_RESET_ERROR"
    - **PowerShell** (as administrator) to get certhash using snippet below:
    ```powershell
  3. unitycoder revised this gist Oct 31, 2023. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -28,12 +28,12 @@ foreach ($cert in $certs) {
    ### TROUBLESHOOTING
    > "SSL Certificate add failed, Error: 1312 A specified logon session does not exist. It may already have been terminated."
    wrong certhash with netsh command
    Wrong certhash with netsh command. Try other ones from the returned list.

    > "The parameter is incorrect."
    dont use ticks or quotes for appid='{...}' in netsh command
    Dont use ticks or quotes for appid='{...}' in netsh command

    > "Secure Connection Failed: Error code: Certificate type not approved for application., SEC_ERROR_INADEQUATE_CERT_TYPE"
    used wrong appid taken from powershell list, use another one.
    Used wrong appid taken from powershell list, use another one.
  4. unitycoder revised this gist Oct 31, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ foreach ($cert in $certs) {


    ### OPTIONAL
    - Open firewall port for incoming TCP 4443 (if you want other computers from LAN to connect)
    - Open firewall port for incoming TCP 4443 (if you want other computers from LAN to connect into your webserver)

    ### UNINSTALLING
    - netsh http delete sslcert ipport=0.0.0.0:4443
  5. unitycoder revised this gist Oct 31, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ### Using HTTPListener with HTTPS
    - **VS**: c# httplistener project, add listener.Prefixes.Add($"https://192.168.1.xxx:4443/"); *or some other ip/port
    - **Browser**: Test connecting into it, error: "Secure Connection Failed : Error code: PR_CONNECT_RESET_ERROR"
    - **PowerShell** (as administrator) to get certhash using snippet below:
  6. unitycoder revised this gist Oct 31, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ foreach ($cert in $certs) {
    ```
    - Pick one of those (2nd one is usually the correct?)
    - "appid" is from your vs studio *.sln solution file, SolutionGuid = <here>
    - **CommandPrompt** (as administrator): netsh http add sslcert ipport=0.0.0.0:4443 certhash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx appid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    - **CommandPrompt** (as administrator): ```netsh http add sslcert ipport=0.0.0.0:4443 certhash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx appid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}```
    - **Browser** test reload: https://192.168.1.xxx:4443
    - **Browser**: Warning about insecure cert (ERR_CERT_AUTHORITY_INVALID), press advanced, Accept and Continue
    - Done!
  7. unitycoder revised this gist Oct 31, 2023. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,20 @@
    - VS: c# httplistener project, add listener.Prefixes.Add($"https://192.168.1.xxx:4443/"); *or some other ip/port
    - Browser: Test connecting into it, error: "Secure Connection Failed : Error code: PR_CONNECT_RESET_ERROR"
    - PowerShell (as administrator) to get certhash using snippet below:
    - **VS**: c# httplistener project, add listener.Prefixes.Add($"https://192.168.1.xxx:4443/"); *or some other ip/port
    - **Browser**: Test connecting into it, error: "Secure Connection Failed : Error code: PR_CONNECT_RESET_ERROR"
    - **PowerShell** (as administrator) to get certhash using snippet below:
    ```powershell
    $certs = Get-ChildItem -Path Cert:\LocalMachine\My
    foreach ($cert in $certs) {
    $thumbprint = $cert.Thumbprint
    $appid = [System.Guid]::NewGuid()
    Write-Host "Certificate certhash: $thumbprint"
    #Write-Host "Application ID (appid): $appid"
    }
    ```
    - Pick one of those (2nd one is usually the correct?)
    - "appid" is from your vs studio *.sln solution file, SolutionGuid = <here>
    - Command prompt (as administrator): netsh http add sslcert ipport=0.0.0.0:4443 certhash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx appid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    - Browser test reload: https://192.168.1.xxx:4443
    - Browser: Warning about insecure cert (ERR_CERT_AUTHORITY_INVALID), press advanced, Accept and Continue
    - **CommandPrompt** (as administrator): netsh http add sslcert ipport=0.0.0.0:4443 certhash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx appid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    - **Browser** test reload: https://192.168.1.xxx:4443
    - **Browser**: Warning about insecure cert (ERR_CERT_AUTHORITY_INVALID), press advanced, Accept and Continue
    - Done!


  8. unitycoder created this gist Oct 31, 2023.
    36 changes: 36 additions & 0 deletions Using HTTPListener with HTTPS.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    - VS: c# httplistener project, add listener.Prefixes.Add($"https://192.168.1.xxx:4443/"); *or some other ip/port
    - Browser: Test connecting into it, error: "Secure Connection Failed : Error code: PR_CONNECT_RESET_ERROR"
    - PowerShell (as administrator) to get certhash using snippet below:
    $certs = Get-ChildItem -Path Cert:\LocalMachine\My
    foreach ($cert in $certs) {
    $thumbprint = $cert.Thumbprint
    $appid = [System.Guid]::NewGuid()
    Write-Host "Certificate certhash: $thumbprint"
    #Write-Host "Application ID (appid): $appid"
    }
    - Pick one of those (2nd one is usually the correct?)
    - "appid" is from your vs studio *.sln solution file, SolutionGuid = <here>
    - Command prompt (as administrator): netsh http add sslcert ipport=0.0.0.0:4443 certhash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx appid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    - Browser test reload: https://192.168.1.xxx:4443
    - Browser: Warning about insecure cert (ERR_CERT_AUTHORITY_INVALID), press advanced, Accept and Continue
    - Done!


    ### OPTIONAL
    - Open firewall port for incoming TCP 4443 (if you want other computers from LAN to connect)

    ### UNINSTALLING
    - netsh http delete sslcert ipport=0.0.0.0:4443

    ### TROUBLESHOOTING
    > "SSL Certificate add failed, Error: 1312 A specified logon session does not exist. It may already have been terminated."
    wrong certhash with netsh command

    > "The parameter is incorrect."
    dont use ticks or quotes for appid='{...}' in netsh command

    > "Secure Connection Failed: Error code: Certificate type not approved for application., SEC_ERROR_INADEQUATE_CERT_TYPE"
    used wrong appid taken from powershell list, use another one.