Skip to content

Commit

Permalink
Enable response wrapping of PKI secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcolby committed Dec 1, 2020
1 parent 7a8642e commit 74d55b7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions hvac/api/secrets_engines/pki.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def rotate_crl(self, mount_point=DEFAULT_MOUNT_POINT):
url=api_path,
)

def generate_intermediate(self, type, common_name, extra_params=None, mount_point=DEFAULT_MOUNT_POINT):
def generate_intermediate(self, type, common_name, extra_params=None, mount_point=DEFAULT_MOUNT_POINT, wrap_ttl=None):
"""Generate Intermediate.
Generates a new private key and a CSR for signing.
Expand All @@ -258,6 +258,8 @@ def generate_intermediate(self, type, common_name, extra_params=None, mount_poin
:type extra_params: dict
:param mount_point: The "path" the method/backend was mounted on.
:type mount_point: str | unicode
:param wrap_ttl: Specifies response wrapping token creation with duration. IE: '15s', '20m', '25h'.
:type wrap_ttl: str | unicode
:return: The JSON response of the request.
:rtype: requests.Response
"""
Expand All @@ -275,6 +277,7 @@ def generate_intermediate(self, type, common_name, extra_params=None, mount_poin
return self._adapter.post(
url=api_path,
json=params,
wrap_ttl=wrap_ttl,
)

def set_signed_intermediate(self, certificate, mount_point=DEFAULT_MOUNT_POINT):
Expand Down Expand Up @@ -305,7 +308,7 @@ def set_signed_intermediate(self, certificate, mount_point=DEFAULT_MOUNT_POINT):
json=params,
)

def generate_certificate(self, name, common_name, extra_params=None, mount_point=DEFAULT_MOUNT_POINT):
def generate_certificate(self, name, common_name, extra_params=None, mount_point=DEFAULT_MOUNT_POINT, wrap_ttl=None):
"""Generate Certificate.
Generates a new set of credentials (private key and certificate) based on the role named in the endpoint.
Expand All @@ -321,6 +324,8 @@ def generate_certificate(self, name, common_name, extra_params=None, mount_point
:name extra_params: dict
:param mount_point: The "path" the method/backend was mounted on.
:name mount_point: str | unicode
:param wrap_ttl: Specifies response wrapping token creation with duration. IE: '15s', '20m', '25h'.
:type wrap_ttl: str | unicode
:return: The JSON response of the request.
:rtype: requests.Response
"""
Expand All @@ -338,6 +343,7 @@ def generate_certificate(self, name, common_name, extra_params=None, mount_point
return self._adapter.post(
url=api_path,
json=params,
wrap_ttl=wrap_ttl,
)

def revoke_certificate(self, serial_number, mount_point=DEFAULT_MOUNT_POINT):
Expand Down Expand Up @@ -465,7 +471,7 @@ def delete_role(self, name, mount_point=DEFAULT_MOUNT_POINT):
url=api_path,
)

def generate_root(self, type, common_name, extra_params=None, mount_point=DEFAULT_MOUNT_POINT):
def generate_root(self, type, common_name, extra_params=None, mount_point=DEFAULT_MOUNT_POINT, wrap_ttl=None):
"""Generate Root.
Generates a new self-signed CA certificate and private key.
Expand All @@ -481,6 +487,8 @@ def generate_root(self, type, common_name, extra_params=None, mount_point=DEFAUL
:type extra_params: dict
:param mount_point: The "path" the method/backend was mounted on.
:type mount_point: str | unicode
:param wrap_ttl: Specifies response wrapping token creation with duration. IE: '15s', '20m', '25h'.
:type wrap_ttl: str | unicode
:return: The JSON response of the request.
:rtype: requests.Response
"""
Expand All @@ -498,6 +506,7 @@ def generate_root(self, type, common_name, extra_params=None, mount_point=DEFAUL
return self._adapter.post(
url=api_path,
json=params,
wrap_ttl=wrap_ttl,
)

def delete_root(self, mount_point=DEFAULT_MOUNT_POINT):
Expand Down

0 comments on commit 74d55b7

Please sign in to comment.