Notifications
Clear all

[Closed] HTTPS connection with GET

How to perform a simple HTTPS GET request, and print the response from the server?
3d max should not slower down!

Thx in advance!

9 Replies

you can use dotnet get in a dotnet background worker something like…

(
 
 	webdata = ""
 
 	fn Completed sender arg =
 	(
 		sender.Dispose();
 		
 		rollout webbrowser_rollout "Web Test" width:800 height:600
 		(
 			 dotNetControl wb "System.Windows.forms.WebBrowser" pos:[10,22] width:780 height:570
 			 on webbrowser_rollout open do 
 			 (
 				wb.ScriptErrorsSuppressed = true;				 
 				wb.DocumentText = webdata
 			 )	 
 		)
 		createdialog webbrowser_rollout
 	)	
 
 	fn getWebData sender arg =
 	(
 		wrGETURL = (dotnetclass "System.Net.WebRequest").Create(arg.Argument);
 		wrGETURL.proxy = (dotnetclass "System.Net.WebProxy").GetDefaultProxy();
 		response = wrGETURL.GetResponse();
 		objstream = response.GetResponseStream()
 		objReader = dotnetobject "System.IO.StreamReader" objStream;
 		sline = "";
 		while sline != undefined do
 		(
 			sLine = objReader.ReadLine();
 			if sLine != undefined then
 				webdata += sline;
 		)	
 	)
 
 	fn GetThePage ip = 
 	(	
 		local thread = dotnetobject "System.ComponentModel.BackGroundWorker"
 		dotnet.addeventhandler thread "DoWork" getWebData;
 		dotNet.addeventhandler thread "RunWorkerCompleted" Completed;
 		thread.RunWorkerAsync ip;
 		thread.IsBusy
 	)
 		
 	(	
 		GetThePage "https://www.google.co.uk/"
 
 	)
 )

great! Thank you so much, Klunk! You’re really the master! Please, can you help me add in the code from above – to accept all server certificates:

ServicePointManager.ServerCertificateValidationCallback =
delegate(object sender, X509Certificate certificate, X509Chain chain,
SslPolicyErrors sslPolicyErrors) { return true; };

as well as

System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
This must be done (one time during the application life cycle) before making the call to the webservice.

and, by the way, with http, I had

httpSock.port.open "GET" "http://website.com/index.php" false
httpSock.port.setRequestHeader "If-Modified-Since" "Sat, 1 Jan 1900 00:00:00 GMT"
httpSock.port.setrequestheader "Content-type" "application/x-www-form-urlencoded"
httpSock.port.send "id=1"

now, how to implement send with https?

Please, anyone, help meeeee!!!

Here is what I could do my self with these data, but I don’t know how to continue.
ServicePointManager is a dotnet class

		myclass = dotNetClass "System.Net.ServicePointManager"
  		myobj = dotnetobject "System.Net.Security.RemoteCertificateValidationCallback"
  		mydelegate = (dotnetclass "Delegate").CreateDelegate

I found here

http://msdn.microsoft.com/library/system.net.servicepointmanager%28v=vs.110%29.aspx

that RemoteCertificateValidationCallback is a Property of ServicePointManager. Am I right that it means that RemoteCertificateValidationCallback is an object?

But I don’t know how to continue.

I have found one more example, may be it could give you a hint

static class Program
{
	static void Main()
	{
		var tcpclient = new TcpClient("remote.example.com", 443);
		var tcpstream = tcpclient.GetStream();
		var sslstream = new SslStream(tcpstream, false, new RemoteCertificateValidationCallback (TrustAllCertificatesCallback));
		sslstream.AuthenticateAsClient("remote.example.com");
		X509Certificate rc = sslstream.RemoteCertificate;
		Console.WriteLine(rc.ToString());
		Console.ReadLine();
	}

	public static bool TrustAllCertificatesCallback( object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors errors)
	{
		return true;
	}
}

solved! Thx for attention


i don’t recommend to use this solution for final product. it HAS TO be used for debugging only

EDITED…
i’ve deleted this post… looked into what it does do i found it absolutely wrong. NEVER DO IT THIS WAY INCLUDING DEBUGGING PURPOSE.

BTW… unlikely this solution will work on Windows 8