@@ -159,34 +159,25 @@ def info(self, label, profile=None):
159159 })
160160 return self .call ('info' , 'POST' , data = data )
161161
162- def init_ca (self , hosts , names , common_name = None , key = None , ca = None ):
162+ def init_ca (self , certificate_request , ca = None ):
163163 """ It initializes a new certificate authority.
164164
165165 Args:
166- hosts (:obj:`iter` of :obj:`cfssl.Host`): Subject Alternative Name(s) for the
167- requested CA certificate.
168- names (:obj:`iter` of :obj:`cfssl.SubjectInfo`): The Subject Info(s) for the
169- requested CA certificate.
170- common_name (:obj:`str`): the common name for the certificate subject in
171- the requested CA certificate.
172- key (:obj:`cfssl.ConfigKey`): Cipher and strength to use for certificate.
173- ca (:obj:`cfssl.ConfigServer`): the CA configuration of the requested CA,
174- including CA pathlen and CA default expiry.
166+ certificate_request (:obj:`cfssl.CertificateRequest`): The certificate
167+ request to use when creating the CA.
168+ ca (:obj:`cfssl.ConfigServer`, optional): The configuration of the
169+ requested Certificate Authority.
175170 Returns:
176171 (:obj:`dict`) Mapping with two keys:
177172 * private key (:obj:`str`): a PEM-encoded CA private key.
178173 * certificate (:obj:`str`): a PEM-encoded self-signed CA certificate.
179174 """
180- key = key or ConfigKey ()
175+ csr_api = certificate_request . to_api ()
181176 data = self ._clean_mapping ({
182- 'hosts' : [
183- host .to_api () for host in hosts
184- ],
185- 'names' : [
186- name .to_api () for name in names
187- ],
188- 'CN' : common_name ,
189- 'key' : key and key .to_api () or ConfigKey ().to_api (),
177+ 'hosts' : csr_api ['hosts' ],
178+ 'names' : csr_api ['names' ],
179+ 'CN' : csr_api ['CN' ],
180+ 'key' : csr_api ['key' ],
190181 'ca' : ca and ca .to_api () or None ,
191182 })
192183 return self .call ('init_ca' , 'POST' , data = data )
0 commit comments