Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for TLS certs in the path used by LXD 3.0 snap #506

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions integration/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ fi
if [ -e /var/snap/lxd/common/lxd/server.crt ]; then
mkdir -p ~/snap/lxd/common/config/servercerts
cp /var/snap/lxd/common/lxd/server.crt ~/snap/lxd/common/config/servercerts/127.0.0.1.crt

# Old snap
if [ -d ~/snap/lxd/current/.config/lxc ]; then
mkdir -p ~/snap/lxd/current/.config/lxc/servercerts
cp /var/snap/lxd/common/lxd/server.crt ~/snap/lxd/current/.config/lxc/servercerts/127.0.0.1.crt
fi
fi

# finally run the integration tests
Expand Down
3 changes: 3 additions & 0 deletions pylxd/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
requests_unixsocket.monkeypatch()

SNAP_ROOT = os.path.expanduser("~/snap/lxd/common/config/")
SNAP_OLD_ROOT = os.path.expanduser("~/snap/lxd/current/.config/lxc")
APT_ROOT = os.path.expanduser("~/.config/lxc/")
CERT_FILE_NAME = "client.crt"
KEY_FILE_NAME = "client.key"
# check that the cert file and key file exist at the appropriate path
if os.path.exists(os.path.join(SNAP_ROOT, CERT_FILE_NAME)): # pragma: no cover
CERTS_PATH = SNAP_ROOT # pragma: no cover
elif os.path.exists(os.path.join(SNAP_OLD_ROOT, CERT_FILE_NAME)): # pragma: no cover
CERTS_PATH = SNAP_OLD_ROOT # pragma: no cover
else: # pragma: no cover
CERTS_PATH = APT_ROOT # pragma: no cover

Expand Down