mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 23:16:36 +02:00
Include epplibwrapper module
This commit is contained in:
parent
d3cc3853c1
commit
ce7cfc1a53
14 changed files with 325 additions and 49 deletions
34
src/epplibwrapper/cert.py
Normal file
34
src/epplibwrapper/cert.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Cert:
|
||||
"""
|
||||
Location of client certificate as written to disk.
|
||||
|
||||
This is needed because the certificate is stored as an environment
|
||||
variable but Python's ssl library requires a file.
|
||||
"""
|
||||
|
||||
def __init__(self, data=settings.SECRET_REGISTRY_CERT) -> None:
|
||||
self.filename = self._write(data)
|
||||
|
||||
def __del__(self):
|
||||
"""Remove the files when this object is garbage collected."""
|
||||
os.unlink(self.filename)
|
||||
|
||||
def _write(self, data) -> str:
|
||||
"""Write data to a secure tempfile. Returns the path."""
|
||||
_, path = tempfile.mkstemp()
|
||||
with open(path, "wb") as file:
|
||||
file.write(data)
|
||||
return path
|
||||
|
||||
|
||||
class Key(Cert):
|
||||
"""Location of private key as written to disk."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__(data=settings.SECRET_REGISTRY_KEY)
|
Loading…
Add table
Add a link
Reference in a new issue