Comment 43 for bug 1820083

Revision history for this message
Heather Lemon (hypothetical-lemon) wrote (last edit ):

#testing steps for python-etcd3gw focal
python version - Python 3.9.7
version tested - python-etcd3gw 0.2.1-3ubuntu1.20.04.1

pull-lp-source python-etcd3gw focal

# generate certs in python-etcd3gw folder
openssl req -x509 -keyout localhost.key -newkey rsa:4096 -nodes -sha256 -out localhost.crt

#download etcd binaries & launch etcd locally with TLS enabled
wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz

tar -zxvf etcd-v3.3.14-linux-amd64.tar.gz

cd etcd-v3.3.14-linux-amd64/

#spin up etcd server
./etcd --name infra0 --data-dir infra0 --cert-file=/python-etcd3gw/localhost.crt --key-file=/python-etcd3gw/localhost.key --advertise-client-urls=https://127.0.0.1:2379 --listen-client-urls=https://127.0.0.1:2379

# test cert connection endpoint
curl --cacert localhost.crt --key localhost.key --cert localhost.crt https://127.0.0.1:2379/health

response
{"health":"true"}

modify test.py to your config setup for etcd

#run test
./test.py

response
success!

# code for test.py
touch test.py
chmod +rwx test.py

gedit test.py
#!/usr/bin/python3

from etcd3gw import Etcd3Client

c = Etcd3Client(host="127.0.0.1", protocol="https", cert_key="localhost.key", cert_cert="localhost.crt", ca_cert="localhost.crt", timeout=10)
c.put('test', 'success!')
resp = c.get('test')
print(b''.join(resp).decode())