Trouble auntentification in LXD and SSL/TLS keys

Hello!

When I run a python-code to my local LXD API I getting error with argument Verify=False:

instance_name = 'pgsql'
api_addr = '127.0.0.1:8443'
certs = ('/home/dv/.config/lxc/client.crt', '/home/dv/.config/lxc/client.key')

response = requests.post(f'https://{api_addr}/1.0/instances/{instance_name}/exec', json={}, cert=certs, verify=False)
response = response.json()

Error:

403 not authorized

How can I get access?

Also I tried with cURL:

curl -k --cert /home/dv/.config/lxc/client.crt --key /home/dv/.config/lxc/client.key -X GET https://127.0.0.1:8443/1.0/instances

Response:

{"type":"error","status":"","status_code":0,"operation":"","error_code":403,"error":"not authorized","metadata":null}

Are you sure that client.crt is trusted by LXD?
You may want to do lxc config trust add ~/.config/lxc/client.crt to make sure.

1 Like

Really, it was necessary to add the certificate to the trust! Thank you! :+1: