Search code examples
nsis

How to request plain HTTP from a website using Inetc


Haya, at the moment im trying to solve a problem in my code regarding a SendRequest error since i believe the website im using (https://www.gnu.org/licenses/gpl-3.0.txt) is not being validated as having a correct certificate by inetc or something close to this - i read here (https://stackoverflow.com/a/26893754/11718125) that to fix this i could use plain http.

how could i go about doing this?


Solution

  • The answer you linked to is old, INetC now supports a /WEAKSECURITY switch.

    To use plain HTTP, just change the https: part in the URL to http:. This does not work everywhere, some servers might force a redirect to HTTPS.

    This works for me:

    Section
    InitPluginsDir
    inetc::get /WEAKSECURITY /SILENT "https://www.gnu.org/licenses/gpl-3.0.txt" "$PluginsDir\License.txt" /END
    ClearErrors
    FileOpen $1 "$PluginsDir\License.txt" r
    IfErrors 0 +2
    Abort "No file?"
    loop:
        FileRead $1 $2
        IfErrors +3
        DetailPrint $2
        Goto loop
    FileClose $1
    SectionEnd