http_tls.bac
' Enable one of these protocols
' Defaults OpenSSL
OPTION TLS TRUE
' We can use these instead
'PRAGMA TLS wolfssl
'PRAGMA TLS gnutls
' Open website
website$ = TOKEN$(ARGUMENT$, 2)
IF LEN(website$) = 0 THEN
PRINT "Enter website as argument!"
END
ENDIF
OPEN website$ & ":443" FOR NETWORK AS mynet
' Now send the GET request
SEND "GET / HTTP/1.1" & DLE$ & "Host: " & website$ & DLE$ & "User-Agent: Mozilla/5.0" & DLE$ & "Accept: text/html" & DLE$ & DLE$ TO mynet
' Fetch data
WHILE WAIT(mynet, 5000)
RECEIVE data$ FROM mynet
total$ = total$ & data$
' Quit receiving data when end indicator was reached
IF REGEX(data$, "</html>") OR LEN(data$) = 0 THEN BREAK
WEND
' Remove chunk indicators from HTML data
PRINT REPLACE$(total$, DLE$ & "[0-9a-fA-F]+" & DLE$, DLE$, TRUE), "-END-"
' Show some information
PRINT "--------------------------"
PRINT GETPEER$(mynet)
PRINT CHOP$(CIPHER$(mynet))
PRINT CA$(mynet)
PRINT CN$(mynet)
' Get the "cacert.pem" file from https://curl.se/docs/caextract.html
IF FILEEXISTS("cacert.pem") THEN PRINT "Validate: ", VERIFY(mynet, "cacert.pem")
PRINT "--------------------------"
' Close and end
CLOSE NETWORK mynet
END
Generated by GNU Enscript 1.6.5.90.