#NEWLINE# def build( self , chainCerts = True ) : #NEWLINE# #INDENT# crtPath = ( self . certPathPrefix + '.crt' ) #NEWLINE# pemPath = os . path . join ( os . path . dirname ( self . certPathPrefix ) , DEFAULT_PEM_NAME ) #NEWLINE# cert = crypto . X509 ( ) #NEWLINE# cert . set_version ( self . security . version ) #NEWLINE# cert . set_serial_number ( self . security . serial ) #NEWLINE# cert . gmtime_adj_notBefore ( ( self . security . notBefore * 3600 ) ) #NEWLINE# cert . gmtime_adj_notAfter ( ( self . security . notAfter * 3600 ) ) #NEWLINE# cert . set_subject ( self . subject . getSubject ( ) ) #NEWLINE# cert . set_issuer ( self . signer . signSubj ) #NEWLINE# cert . set_pubkey ( self . security . getKey ( ) ) #NEWLINE# extList = [ ] #NEWLINE# for ext in self . extensions : #NEWLINE# #INDENT# extList . append ( crypto . X509ExtensionType ( ext . name ( ) , ext . criticality ( ) , ext . value ( ) ) ) #NEWLINE# #UNINDENT# cert . add_extensions ( extList ) #NEWLINE# if self . modifier . hasPreSign : #NEWLINE# #INDENT# cert = self . asnModify ( cert , self . modifier . preSign ) #NEWLINE# #UNINDENT# cert . sign ( self . signer . getKey ( ) , self . security . digest ) #NEWLINE# if self . modifier . hasPostSign : #NEWLINE# #INDENT# cert = self . asnModify ( cert , self . modifier . postSign ) #NEWLINE# #UNINDENT# with open ( crtPath , 'wb+' ) as f : #NEWLINE# #INDENT# f . write ( crypto . dump_certificate ( crypto . FILETYPE_PEM , cert ) ) #NEWLINE# #UNINDENT# if self . modifier . hasPostWrite : #NEWLINE# #INDENT# self . modifier . postWrite ( self . modifier , self . certPathPrefix ) #NEWLINE# #UNINDENT# if chainCerts : #NEWLINE# #INDENT# if ( not os . path . exists ( pemPath ) ) : #NEWLINE# #INDENT# with open ( pemPath , 'wb+' ) as f : #NEWLINE# #INDENT# if self . signer . signPathPrefix : #NEWLINE# #INDENT# rootPem = ( self . signer . signPathPrefix + '.pem' ) #NEWLINE# if os . path . exists ( rootPem ) : #NEWLINE# #INDENT# with open ( rootPem , 'rb' ) as r : #NEWLINE# #INDENT# f . write ( r . read ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# concatFiles ( crtPath , pemPath , pemPath ) #NEWLINE# #UNINDENT# self . cert = cert #NEWLINE# return cert