cryptol/cryptol-remote-api/test-cryptol-remote-api.py
Lisanna Dettwyler dfae4580e3
Support TLS in cryptol-remote-api (#1203)
Add support for TLS connections in both the rpc server
and client. Allow the client to disable certificate validation
via the `verify` keyword argument, i.e.,
`cryptol.connect(verify=False)`. The docker container
for `cryptol-remote-api` also contains a self-signed
cert for testing purposes.

Co-authored-by: Andrew Kent <andrew@galois.com>
2021-06-25 14:26:09 -07:00

20 lines
562 B
Python

import sys
import argo_client.connection as argo
import cryptol
connType = sys.argv[1]
host = sys.argv[2]
port = int(sys.argv[3])
if connType == 'socket':
c = cryptol.connect(argo.RemoteSocketProcess(host, port=port, ipv6=False))
elif connType == 'http':
c = cryptol.connect(url="http://%s:%d/" % (host,port))
elif connType == 'https':
c = cryptol.connect(url="https://%s:%d/" % (host,port))
else:
raise Exception('specify socket, http, or https for connection type')
c.load_module('Cryptol')
assert c.evaluate_expression("1+1").result() == 2