1717
1818from __future__ import print_function
1919
20- from vcert import (CertificateRequest , Connection , RevocationRequest , CSR_ORIGIN_SERVICE )
20+ from vcert import (CertificateRequest , venafi_connection , RevocationRequest , CSR_ORIGIN_SERVICE )
2121import string
2222import random
2323import logging
@@ -36,12 +36,11 @@ def main():
3636 zone = environ .get ("TPP_ZONE" )
3737 server_trust_bundle = environ .get ('TPP_TRUST_BUNDLE' )
3838
39-
4039 # Connection will be chosen automatically based on which arguments are passed.
4140 # If token is passed Venafi Cloud connection will be used.
4241 # If user, password, and URL Venafi Platform (TPP) will be used.
43- conn = Connection (url = url , user = user , password = password ,
44- http_request_kwargs = {"verify" : server_trust_bundle })
42+ conn = venafi_connection (url = url , user = user , password = password ,
43+ http_request_kwargs = {"verify" : server_trust_bundle })
4544 # If your TPP server certificate signed with your own CA, or available only via proxy, you can specify
4645 # a trust bundle using requests vars:
4746 # conn = Connection(url=url, token=token, user=user, password=password,
@@ -90,31 +89,6 @@ def main():
9089 fn .write (new_request .private_key_pem )
9190 fn .close ()
9291
93- revocation_req = RevocationRequest (req_id = request .id , comments = "Just for test" )
94- print ("Revoke" , conn .revoke_cert (revocation_req ))
95-
96- print ("Trying to sign CSR" )
97- csr_pem = open ("example-csr.pem" , "rb" ).read ()
98- csr_request = CertificateRequest (csr = csr_pem .decode ())
99- # zone_config = conn.read_zone_conf(zone)
100- # request.update_from_zone_config(zone_config)
101- conn .request_cert (csr_request , zone )
102-
103- # and wait for signing
104- while True :
105- cert = conn .retrieve_cert (csr_request )
106- if cert :
107- break
108- else :
109- time .sleep (5 )
110-
111- # after that print cert and key
112- print (cert .full_chain )
113- # and save into file
114- f = open ("/tmp/signed-cert.pem" , "w" )
115- f .write (cert .full_chain )
116- f .close ()
117-
11892
11993def random_word (length ):
12094 letters = string .ascii_lowercase
0 commit comments