How can I make an HTTPS request in Squeak or Pharo?
-
10-10-2019 - |
문제
How can I make an HTTPS request from Squeak or Pharo? HTTPClient
and friends seem to lack any facilities for SSL.
해결책
Zodiac as mentioned above will enable you to make HTTPS requests from Zinc.
Enable it like this (recipe from the Pharo forum):
First download the SqueakSSL plugin and put it in your Pharo directory, and then load the necessary packages:
"Load Zinc HTTP Components" Gofer it squeaksource: 'ZincHTTPComponents'; package: 'Zinc-HTTP'; package: 'Zinc-Tests'; package: 'Zinc-Patch-HTTPSocket'; load. "Load Zodiac including extras" Gofer it squeaksource: 'Zodiac'; package: 'Zodiac-Core'; package: 'Zodiac-Tests'; load. "Load extra Zinc support for Zodiac" Gofer it squeaksource: 'ZincHTTPComponents'; package: 'Zinc-Zodiac'; load. "Switch to the Zn Zodiac socket factory" ZnNetworkingUtils default: ZnZodiacNetworkingUtils new.
And you should be able to make requests against HTTPS resources.
다른 팁
You can use SqueakSSL easily through WebClient like so:
WebClient httpGet: 'https://www.google.com/search?q=squeak'.
There may be a problem with certificates, in which case you will have to catch and ignore the errors (see here).
Also, keep your eye on the Zinc http framework, which will be Pharo's new default soon. It doesn't seem to have ssl yet, but it's being rapidly developed.
There was a bit of discussion on the mailing list. In short:
SqueakSSL is supposed to do the job, but may need some fixing. It can be invoked through WebClient, as Sean Denigris noted:
WebClient httpGet: 'https://www.google.com/search?q=squeak'.
And, from the mailing list:
If you know whom you want to connect to, then you can use stunnel.
In a production environment we just use Lighttpd (or Apache) to translate from http to https
You might want to use stunnel.
Why?
To outsource completely the CPU intensive encryption/decryption tasks to a native library and free the VM of that stress at all.
In the other hand, you might want to keep an eye on Zodiac that started by this initiative
In recent Pharo images the support is much better since Zinc and Zodiac are integrated. Just evaluate
ZnEasy get: 'https://www.google.com'
for example.
A detailed docu can be found here:
http://www.pharo-project.org/news?dialog=documentation-for-zinc-http
For HTTPS client, Secure POP client, Secure SMTP client read