4040from .ssh_utils import SSHCertRequest , SSHRetrieveResponse , SSHCATemplateRequest , SSHConfig
4141from .tpp_utils import IssuerHint
4242
43- MIME_JSON = "application/json"
44- MIME_HTML = "text/html"
45- MIME_TEXT = "text/plain"
46- MIME_CSV = "text/csv"
47- MIME_ANY = "*/*"
48- LOCALHOST = "127.0.0.1"
43+ MIME_JSON = 'application/json'
44+ MIME_HTML = 'text/html'
45+ MIME_TEXT = 'text/plain'
46+ MIME_CSV = 'text/csv'
47+ MIME_ANY = '*/*'
48+ MIME_OCTET_STREAM = 'application/octet-stream'
49+ LOCALHOST = '127.0.0.1'
4950DEFAULT_TIMEOUT = 180
50- CSR_ORIGIN_PROVIDED = " provided"
51- CSR_ORIGIN_LOCAL = " local"
52- CSR_ORIGIN_SERVICE = " service"
53- CHAIN_OPTION_FIRST = " first"
54- CHAIN_OPTION_LAST = " last"
55- CHAIN_OPTION_IGNORE = " ignore"
51+ CSR_ORIGIN_PROVIDED = ' provided'
52+ CSR_ORIGIN_LOCAL = ' local'
53+ CSR_ORIGIN_SERVICE = ' service'
54+ CHAIN_OPTION_FIRST = ' first'
55+ CHAIN_OPTION_LAST = ' last'
56+ CHAIN_OPTION_IGNORE = ' ignore'
5657
5758
5859class CertField :
@@ -221,33 +222,32 @@ def __str__(self):
221222 return self .name
222223
223224
224- class RecommendedSettings :
225- def __init__ (self , subject_o_value = None , subject_ou_value = None , subject_l_value = None , subject_st_value = None ,
226- subject_c_value = None , key_type = None , key_reuse = None ):
227- """
228- :param str subject_o_value:
229- :param str subject_ou_value:
230- :param str subject_l_value:
231- :param str subject_st_value:
232- :param str subject_c_value:
233- :param KeyType key_type:
234- :param bool key_reuse:
235- """
236- self .subjectOValue = subject_o_value
237- self .subjectOUValue = subject_ou_value
238- self .subjectLValue = subject_l_value
239- self .subjectSTValue = subject_st_value
240- self .subjectCValue = subject_c_value
241- self .keyType = key_type
242- self .keyReuse = key_reuse
243-
244-
245225class CertificateRequest :
246- def __init__ (self , cert_id = None , san_dns = None , email_addresses = "" , ip_addresses = None , user_principal_names = None ,
247- uniform_resource_identifiers = None , attributes = None , key_type = None , private_key = None , key_password = None ,
248- csr = None , friendly_name = None , common_name = None , thumbprint = None , organization = None ,
249- organizational_unit = None , country = None , province = None , locality = None , origin = None , custom_fields = None ,
250- timeout = DEFAULT_TIMEOUT , csr_origin = CSR_ORIGIN_LOCAL , include_private_key = False , validity_hours = None ,
226+ def __init__ (self , cert_id = None ,
227+ san_dns = None ,
228+ email_addresses = "" ,
229+ ip_addresses = None ,
230+ user_principal_names = None ,
231+ uniform_resource_identifiers = None ,
232+ attributes = None ,
233+ key_type = None ,
234+ private_key = None ,
235+ key_password = None ,
236+ csr = None ,
237+ friendly_name = None ,
238+ common_name = None ,
239+ thumbprint = None ,
240+ organization = None ,
241+ organizational_unit = None ,
242+ country = None ,
243+ province = None ,
244+ locality = None ,
245+ origin = None ,
246+ custom_fields = None ,
247+ timeout = DEFAULT_TIMEOUT ,
248+ csr_origin = CSR_ORIGIN_LOCAL ,
249+ include_private_key = False ,
250+ validity_hours = None ,
251251 issuer_hint = IssuerHint .DEFAULT ):
252252 """
253253 :param str cert_id: Certificate request id. Generating by server.
@@ -259,11 +259,16 @@ def __init__(self, cert_id=None, san_dns=None, email_addresses="", ip_addresses=
259259 :param attributes:
260260 :param KeyType key_type: Type of asymmetric cryptography algorithm. Default is RSA 2048.
261261 :param asymmetric.PrivateKey private_key: String with pem encoded private key or asymmetric.PrivateKey
262- :param str key_password: Password for encrypted private key. Not supported at this moment.
262+ :param str key_password: Password for encrypted private key.
263263 :param str csr: Certificate Signing Request in pem format
264264 :param str friendly_name: Name for certificate in the platform. If not specified common name will be used.
265265 :param str common_name: Common name of certificate. Usually domain name.
266266 :param str thumbprint: Certificate thumbprint. Can be used for identifying certificate on the platform.
267+ :param organization:
268+ :param organizational_unit:
269+ :param country:
270+ :param province:
271+ :param locality:
267272 :param str origin: application identifier
268273 :param list[CustomField] custom_fields: list of custom fields values to be added to the certificate.
269274 :param int timeout: Timeout for the certificate to be retrieved from server. Measured in seconds.
@@ -582,32 +587,6 @@ def __init__(self, user=None, password=None, access_token=None, refresh_token=No
582587 self .state = state
583588
584589
585- class AppDetails :
586- def __init__ (self , app_id = None , cit_map = None , company_id = None , name = None , description = None ,
587- owner_ids_and_types = None , fq_dns = None , internal_fq_dns = None , external_ip_ranges = None ,
588- internal_ip_ranges = None , internal_ports = None , fully_qualified_domain_names = None , ip_ranges = None ,
589- ports = None , org_unit_id = None ):
590- """
591- :param str app_id:
592- :param dict cit_map:
593- """
594- self .app_id = app_id
595- self .cit_alias_id_map = cit_map
596- self .company_id = company_id
597- self .name = name
598- self .description = description
599- self .owner_ids_and_types = owner_ids_and_types
600- self .fq_dns = fq_dns
601- self .internal_fq_dns = internal_fq_dns
602- self .external_ip_ranges = external_ip_ranges
603- self .internal_ip_ranges = internal_ip_ranges
604- self .internal_ports = internal_ports
605- self .fully_qualified_domain_names = fully_qualified_domain_names
606- self .ip_ranges = ip_ranges
607- self .ports = ports
608- self .org_unit_id = org_unit_id
609-
610-
611590class CommonConnection :
612591
613592 def auth (self ):
@@ -702,6 +681,11 @@ def retrieve_ssh_config(self, ca_request):
702681
703682 @staticmethod
704683 def process_server_response (r ):
684+ """
685+
686+ :param requests.Response r:
687+ :rtype: str or dict
688+ """
705689 if r .status_code not in (HTTPStatus .OK , HTTPStatus .ACCEPTED , HTTPStatus .CREATED , HTTPStatus .CONFLICT ):
706690 try :
707691 log_errors (r .json ())
@@ -727,6 +711,9 @@ def process_server_response(r):
727711 elif content_type .startswith (MIME_CSV ):
728712 log .debug (r .content .decode ())
729713 return r .status_code , r .content .decode ()
714+ elif content_type .startswith (MIME_OCTET_STREAM ):
715+ log .debug (r .content )
716+ return r .status_code , r .content
730717 else :
731718 log .error ("Unexpected content type: %s for request %s" % (content_type , r .request .url ))
732719 raise ServerUnexptedBehavior
0 commit comments