Hello,
I’m attempting to communicate with the Verisign EPP server over a TCP / SSL connection. This connection requires an SSL certificate, but I’m having trouble with the SSL certificate. I am inexperienced in working with anything like this, in the past all I’ve done is use Req to send various requests of different verbs. So has anyone written a library to make this easier? Or can anyone assist in the correct configuration of including an SSL certificate, sending a request and listening for a response? Here’s what I have so far, just shooting in the dark:
def ssl_client() do
host = Application.get_env(:appname, :epp_host) |> String.to_charlist()
port = Application.get_env(:appname, :epp_port)
cert = File.cwd!() <> "/ssl/cert.chain.pem"
{:ok, connect_socket} =
:ssl.connect(host, port, [verify: :verify_none, cacertfile: cert, active: true], :infinity)
connect_socket
end
defp listen_ssl(socket) do
case :ssl.recv(socket, 0) do
{:ok, line} ->
IO.puts(~s(Client got: "#{String.trim(line)}"))
:ok = :ssl.close(socket)
{:error, :closed} ->
IO.puts("Server closed socket.")
{:error, :enotconn} ->
IO.puts("Server is not connected.")
{:error, reason} ->
IO.puts("Server errored with code: #{reason}")
end
end
def send_ssl_request(line) do
socket = ssl_client()
:ssl.send(socket, line)
listen_ssl(socket)
end
The response that I get when I attempt to call send_ssl_request()
is:
TLS :client: In state :connection received SERVER ALERT: Fatal - Bad Certificate
Thanks!