Forum Discussion
dreamer2057
10 years agoChannel Surfer
Something like this:
It needed if you have ca certificate file that makes domain trusted from untrusted, otherwise
If all will be good: code will be 200 and data will be in correct format (valid json), then need continue to thinking
Function TestHttps() as Dynamic
print "HTTPS STARTED"
url = " ... enter url "
timeout = 1500
num_retries = 1
http = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
http.SetUrl(url)
http.SetMessagePort(port)
http.SetRequest("POST")
http.AddHeader("Content-Type", "application/json")
http.AddHeader("X-Roku-Reserved-Dev-Id")
http.SetCertificatesFile("pkg:/source/certificates/cafile.pem")
http.EnableHostVerification(true)
http.EnablePeerVerification(true)
http.InitClientCertificates()
http.RetainBodyOnError(true)
while num_retries > 0
if (http.AsyncPostFromString(""))
event = wait(timeout, http.GetPort())
print event
if type(event) = "roUrlEvent"
dd = event.GetString()
code = event.GetResponseCode()
print code
if code = 200
print "HTTPS data:" + dd
print "HTTPS code:" + ToString(code)
return dd
else
print "HTTPS data:" + dd
print "HTTPS code:" + ToString(code)
timeout = timeout * 2
num_retries = num_retries - 1
print "HTTPS New try: " + ToString(num_retries)
endif
else
timeout = timeout * 2
num_retries = num_retries - 1
print "HTTPS New try: " + ToString(num_retries)
endif
endif
end while
print "HTTPS FINISHED"
End Function
http.SetCertificatesFile("pkg:/source/certificates/cafile.pem")It needed if you have ca certificate file that makes domain trusted from untrusted, otherwise
http.SetCertificatesFile ("common:/certs/ca-bundle.crt")If all will be good: code will be 200 and data will be in correct format (valid json), then need continue to thinking