Skip to content

Commit

Permalink
Simplify fingerprint retrieval in Certificates.create()
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
  • Loading branch information
simondeziel committed Apr 26, 2022
1 parent 1cfd6af commit ccdbfbb
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions pylxd/models/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import binascii

from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
Expand Down Expand Up @@ -61,13 +59,9 @@ def create(cls, client, password, cert_data):
"certificate": base64_cert,
"password": password,
}
client.api.certificates.post(json=data)

# XXX: rockstar (08 Jun 2016) - Please see the open lxd bug here:
# https://github.com/lxc/lxd/issues/2092
fingerprint = binascii.hexlify(cert.fingerprint(hashes.SHA256())).decode(
"utf-8"
)
response = client.api.certificates.post(json=data)
location = response.headers['Location']
fingerprint = location.split("/")[-1]
return cls.get(client, fingerprint)

@property
Expand Down

0 comments on commit ccdbfbb

Please sign in to comment.