How to use HTTPClient to connect to a ssl site?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By azurvii
:warning: Old Version Published before Godot 3 was released.

What I have is something like:

httpClient.connect("abc.appspot.com", 443, true)

Later I call httpClient.poll() then I check httpClient.get_status() to see how the connection is going. However, the program ends abruptly and silently without any debug info/error/etc. Well, Mac OS has a crash log, but that’s some language I don’t understand. With breakpoints I found it ends at httpClient.poll() function at a point, but I have not enough knowledge to trace into the Godot’s C++ source.

I searched a bit about it and I thought this was due to the OpenSSL integration issue with 2.0.2 and the master I compiled at that time. But when I tried with 2.0.3, which was said to have the openssl re-enabled in the official build, it still crashes silently.

I started to doubt that it was me who didn’t use it the right way, so I asked here. Any help/sample code/leads would be much appreciated!

:bust_in_silhouette: Reply From: vinod

I didn’t checked in the current version. But once I made an openclipart plugin. I was getting some similar errors because openclipart website is SSL enabled. Godot require a client side certificate to validate the SSL connection. So I copied one from my computer and chose that as ssl certificate path in Godot project settings. After that, it did work.

Check this:

I am not sure if it works. Try it.

Thanks @vinod, I’ll go and check this out. However I have been unable to configure the ssl – I was following http://docs.godotengine.org/en/latest/tutorials/ssl_certificates.html, which seems not applicable to the current version. I raised an issue with godot-docs to check how I can achieve cert configuration.

azurvii | 2016-05-16 14:41

:bust_in_silhouette: Reply From: azurvii

@vinod pointed out part of the answer, which is the crt file configuration needed. The crt file should be a PEM file containing public keys to verify the web site you are visiting. More details are in http://docs.godotengine.org/en/latest/tutorials/ssl_certificates.html (this is not the way at least in 2.0.{2,3}, in which you need to manually specify the ssl category and then add a certificates variable).

From what I found, that’s not enough. openssl itself does not seem to be properly enabled in 2.0.{2,3} releases. I debugged the engine (@commit 926495d) and found the sudden termination happens at StreamPeerSSL::create(), which in turn calls the function StreamPeerSSL::_create points to, which again at runtime is a NULL pointer. I found the whole ssl facilities are not initialized at all. And that was due to that in SConstruct file, openssl option has been commented out. Re-enabling the openssl option by remove the commenting, the SSL works just fine in HTTPClient.