Skip to content

Support TLS in cryptol-remote-api#1203

Merged
pnwamk merged 46 commits intomasterfrom
ldettwy/explore-cryptol-remote-1008
Jun 25, 2021
Merged

Support TLS in cryptol-remote-api#1203
pnwamk merged 46 commits intomasterfrom
ldettwy/explore-cryptol-remote-1008

Conversation

@lisanna-dettwyler
Copy link
Contributor

@lisanna-dettwyler lisanna-dettwyler commented May 27, 2021

Use scotty-tls to add TLS support to cryptol-remote-api.

Closes #1008

@lisanna-dettwyler lisanna-dettwyler self-assigned this May 27, 2021
@lisanna-dettwyler
Copy link
Contributor Author

This isn't building right now because there's a compatibility issue with the scotty-tls in hackage and warp: scotty-web/scotty-tls#8

https://gitpod.io#snapshot/d3211af8-74e6-496a-adbb-8bf4a3d67660

@lisanna-dettwyler
Copy link
Contributor Author

lisanna-dettwyler commented Jun 9, 2021

TLS usage:

# Generate a certificate. Self-signed example:
openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr \
    -subj "/C=GB/ST=London/L=London/O=Acme Widgets/OU=IT Department/CN=localhost"
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

# Change owner uid of the certificate and key to `1000` to match cryptol user in container image:
chown 1000 server.crt server.key

# Start server:
docker run --rm -ti --detach \         
  -v $PWD/server.crt:/home/cryptol/server.crt \
  -v $PWD/server.key:/home/cryptol/server.key \
  -e TLS_ENABLE=1 \
  -p 443:8080 \
  ghcr.io/galoisinc/cryptol-remote-api:tls-demo

# Connect to server
curl -k \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -XPOST \
  -d '{"jsonrpc":"2.0","id":1,"method":"load module","params":{"module name":"Cryptol","state":null}}' \
  https://localhost/

Result:

{
  "result": {
    "state": "81ecbea3-6a4c-49a3-abe3-853b90cb18cb",
    "stdout": "",
    "stderr": "",
    "answer": []
  },
  "jsonrpc": "2.0",
  "id": 1
}

@pnwamk
Copy link
Contributor

pnwamk commented Jun 23, 2021

GaloisInc/argo#165 has been merged - of note:

  • the TLS_ENABLE env var can be set to a nonzero, nonempty string value to enable TLS for the argo server run in http mode
  • The underlying argo python client now has a verify keyword argument that can be used to disable certificate verification for TLS connections.
  • argo now depends on scotty-tls as a submodule until v0.4.2 is published to hackage (do we need it to be a submodule for cryptol as well...?)

@pnwamk pnwamk marked this pull request as ready for review June 23, 2021 23:07
@pnwamk pnwamk merged commit dfae458 into master Jun 25, 2021
@pnwamk pnwamk deleted the ldettwy/explore-cryptol-remote-1008 branch June 25, 2021 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable cryptol-remote-api over HTTPS

2 participants