#NEWLINE# def storeCert( self , certString , id ) : #NEWLINE# #INDENT# '\n        Takes a string representation of a PEM-encoded certificate and\n        a nodeid as input. If the string is a valid PEM-encoded certificate\n        and the CA of the the certificate is present in the trustedStore of\n        this node, the certificate is stored in the DHT and written to disk\n        for later use.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# cert = OpenSSL . crypto . load_certificate ( OpenSSL . crypto . FILETYPE_PEM , certString ) #NEWLINE# store_ctx = OpenSSL . crypto . X509StoreContext ( self . trustedStore , cert ) #NEWLINE# store_ctx . verify_certificate ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# logger ( self . sourceNode , 'The certificate for {} is not signed by a trusted CA!' . format ( id ) ) #NEWLINE# return #NEWLINE# #UNINDENT# exists = self . storage . get ( digest ( '{}cert' . format ( id ) ) ) #NEWLINE# if ( not exists [ 0 ] ) : #NEWLINE# #INDENT# self . storage [ digest ( '{}cert' . format ( id ) ) ] = certString #NEWLINE# name_dir = os . path . join ( self . cert_conf [ 'CA_default' ] [ 'runtimes_dir' ] , self . name ) #NEWLINE# file = open ( os . path . join ( name_dir , 'others' , '{}.pem' . format ( id ) ) , 'w' ) #NEWLINE# file . write ( certString ) #NEWLINE# file . close ( )