def DER_cert_to_PEM_cert(der_cert_bytes):
 if hasattr(base64, 'standard_b64encode'):
  f = base64.standard_b64encode(der_cert_bytes)
  rval = (PEM_HEADER + '\n')
  while (len(f) > 0):
   l = min(len(f), 64)
   rval += (f[:l] + '\n')
   f = f[l:]
  rval += (PEM_FOOTER + '\n')
  return rval
 else:
  return ((((PEM_HEADER + '\n') + base64.encodestring(der_cert_bytes)) + PEM_FOOTER) + '\n')

def DER_cert_to_PEM_cert ( der_cert_bytes ) : if hasattr ( base64 , 'standard_b64encode' ) : f = base64 . standard_b64encode ( der_cert_bytes ) rval = ( PEM_HEADER + '\n' ) while ( len ( f ) > 0 ) : l = min ( len ( f ) , 64 ) rval += ( f [ : l ] + '\n' ) f = f [ l : ] rval += ( PEM_FOOTER + '\n' ) return rval else : return ( ( ( ( PEM_HEADER + '\n' ) + base64 . encodestring ( der_cert_bytes ) ) + PEM_FOOTER ) + '\n' )
takes a certificate in binary der format and returns the pem version of it as a string .