Docker Engine provides encrypted API(works on HTTPS (SSL/TLS)) that requires:
- ca.pem (CA Certificate)
- cert.pem (Client Certificate )
- key.pem (Client Key) while sending an API request.
https://docs.docker.com/engine/security/protect-access/
In python, I am able to pass these certificates using the requests method to send a request to the server (Client-side):
import requests
CA_CERT = './ssl-tls-keys/ca.pem'
CLIENT_CERT = './ssl-tls-keys/cert.pem'
CLIENT_KEY = './ssl-tls-keys/key.pem'
URL = 'https://65.0.95.227:2376/containers/json?all=1'
def get_container_list():
response = requests.get(url=URL, cert=(CLIENT_CERT, CLIENT_KEY),
verify=CA_CERT)
return response.json()
def print_containers_data():
for container in get_container_list():
print('Container [Id: %s, Name: %s, Status: %s]' %
(container['Id'], container['Names'][0], container['Status']))
print_containers_data()
Using curl, We can send the request using:
curl https://$HOST:2376/images/json \
--cert cert.pem \
--key key.pem \
--cacert ca.pem
I am not able to figure out how can I use these 3 certificates while sending the https request to the Docker Engine API in flutter.
I tried using HTTP and DIO packages but didn't find anything there.