Esempio n. 1
0
   def testSaveAndLoadString(self):
      cert = Certificate(subject="test")
      cert.add_extension("subjectAltName", 0, "URI:http://foovalue")

      # create an issuer and sign the certificate
      issuerKey = Keypair(create=True)
      issuerSubject = "testissuer"
      cert.set_issuer(issuerKey, issuerSubject)
      cert.sign()

      certstr = cert.save_to_string()

      #print certstr

      cert2 = Certificate()
      cert2.load_from_string(certstr)

      # read back the subject and make sure it is correct
      subj = cert2.get_subject()
      self.assertEqual(subj, "test")

      # read back the issuer and make sure it is correct
      issuerName = cert2.get_issuer()
      self.assertEqual(issuerName, "testissuer")

      # read back the extension and make sure it is correct
      self.assertEqual(cert2.get_extension("subjectAltName"),
                       "URI:http://foovalue")
Esempio n. 2
0
File: sfi.py Progetto: planetlab/sfa
 def get_trusted_certs(self, opts, args):
     """
     return uhe trusted certs at this interface 
     """ 
     trusted_certs = self.registry.get_trusted_certs()
     for trusted_cert in trusted_certs:
         gid = GID(string=trusted_cert)
         gid.dump()
         cert = Certificate(string=trusted_cert)
         self.logger.debug('Sfi.get_trusted_certs -> %r'%cert.get_subject())
     return 
Esempio n. 3
0
 def testSetAndGetSubject(self):
    cert = Certificate()
    cert.create()
    cert.set_subject("test")
    subj = cert.get_subject()
    self.assertEqual(subj, "test")