Reputation: 359
I have an erlang application and it needs to connect to a php application hosted on Apache with HTTPS. How do I install the client certificate on my erlang machine?
Upvotes: 1
Views: 1399
Reputation: 2544
The SSL module of Erlang/OTP which is the interface for Secure Socket Layer has an option for defining client side certificate:
{cacertfile, path()}
Path to a file containing PEM-encoded CA certificates. The CA certificates are used during server authentication and when building the client certificate chain.
Now if you want to use an HTTP client with the support of client side ssl certificate instead of writing everything by yourself, you have some options:
1. HTTPC: This is the default HTTP client of OTP.
SSLOptions = [{cacertfile, "/path/to/cert/file"}],
HTTPOptions = [{ssl, SSLOptions}],
%% ... define Method, Request and Options ...
httpc:request(Method, Request, HTTPOptions, Options),
2. Hackney: This is a third party and simple HTTP client.
SSLOptions = [{cacertfile, "/path/to/cert/file"}],
Options = [{ssl_options, SSLOptions}],
%% ... define Method, URL, Headers and Payload ...
hackney:request(Method, URL, Headers, Payload, Options),
Here you can see a full list of client side ssl options which can be used.
Upvotes: 4