Esempio n. 1
0
    def service_getCertificatesInfo(self, ctx):
        """
        Return information about certifiates/eky currently set, in the form of a dictionnary:
        {
            'cert'  : ['brief description', 'certificate content'],
            'key'   : ['md5 of the key', ''],
            'ca'    : ['brief description', 'CA content'],
            'crl'   : ['brief description', 'CRL content'],
        }
        """
        infos = {
            'cert' :    [tr('No certificate set'), tr('No certificate has been set yet')],
            'key' :     [tr('No key set'), ''],
            'ca' :      [tr('No CA is set'), tr('No certificate authority has been set yet')],
            'crl' :     [tr('No CRL set'), tr('No certificate revocation list has been set yet')],
        }

        # Certificate
        try:
            if isfile(self.CERT_PATH):
                cert = load_cert(self.CERT_PATH)
                infos['cert'][0] = unicode(cert.get_subject())
                infos['cert'][1] = unicode(cert.as_text())
        except Exception, error:
            infos['cert'][0] = tr('Invalid certificate')
            self.cert_logger.debug("Invalid cert : %s" % error)
Esempio n. 2
0
def gridLocalUserMapping():
    global gridMapFile, userGridProxy
    
    print ("searching local user mapping based on grid proxy '%s' consulting "
           "gridmapfile '%s'" % (userGridProxy, gridMapFile))
    
    checker = GridMapChecker(gridMapFile)
    # Proxy will later be an instance with attributes properly set
    proxy = Proxy() # create an empty one
    # calls external openssl program ...
    subject = proxy.getSubject(userGridProxy)
    print "proxy subject: '%s'" % subject
    localUser = checker.requestLocalId(subject)
    print "local user: '******'" % localUser
    
    print "\n\n\n"
    from M2Crypto.X509 import load_cert
    cert = load_cert("pyro-ssl-example/certs/server.crt")
    print "subject read by M2Crypto: '%s'" % cert.get_subject()
    
    cert = load_cert(userGridProxy)
    print "subject read by M2Crypto: '%s'" % cert.get_subject()    
Esempio n. 3
0
def gridLocalUserMapping():
    global gridMapFile, userGridProxy

    print ("searching local user mapping based on grid proxy '%s' consulting "
           "gridmapfile '%s'" % (userGridProxy, gridMapFile))

    checker = GridMapChecker(gridMapFile)
    # Proxy will later be an instance with attributes properly set
    proxy = Proxy()  # create an empty one
    # calls external openssl program ...
    subject = proxy.getSubject(userGridProxy)
    print("proxy subject: '%s'" % subject)
    localUser = checker.requestLocalId(subject)
    print("local user: '******'" % localUser)

    print("\n\n\n")
    from M2Crypto.X509 import load_cert
    cert = load_cert("pyro-ssl-example/certs/server.crt")
    print("subject read by M2Crypto: '%s'" % cert.get_subject())

    cert = load_cert(userGridProxy)
    print("subject read by M2Crypto: '%s'" % cert.get_subject())
Esempio n. 4
0
def binary():
	f = open('signature.txt')
	signature = f.read()

	c = load_cert('new_cert.x509')

	k = c.get_pubkey()

	k.verify_init()

	data = 'Jesus is Lord'

	k.verify_update(data)

	result = k.verify_final(signature)

	print 'verification result: ', result
Esempio n. 5
0
 def showCertificate(self, attr):
     filename = getattr(self.ssl_options, attr)
     if filename:
         try:
             cert = load_cert(filename)
             txt = cert.as_text()
         except X509Error:
             txt = tr("Selected file is not a PEM encoded certificate.")
         except IOError:
             txt = tr("Unable to read the certificate.")
     else:
         txt = tr("No certificate selected")
     widget = getattr(self, attr + "_text")
     widget.document().setPlainText(txt)
     scrollbar = widget.horizontalScrollBar()
     scrollbar.setValue(scrollbar.minimum())
     scrollbar = widget.verticalScrollBar()
     scrollbar.setValue(scrollbar.minimum())
Esempio n. 6
0
def dobase64():
	f = open('signature.txt')

	b64 = f.read()

	signature = base64.b64decode(b64)	

	c = load_cert('new_cert.x509')

	k = c.get_pubkey()

	k.verify_init()

	data = 'Jesus is Lord'

	k.verify_update(data)

	result = k.verify_final(signature)

	print 'verification result: ', result
Esempio n. 7
0
        # Private key
        try:
            if isfile(self.KEY_PATH):
                with open(self.KEY_PATH, 'rb') as key:
                    hash_md5 = md5()
                    hash_md5.update(key.read())
                    infos['key'][0] = u'MD5: ' + unicode(hash_md5.hexdigest())
        except Exception, error:
            infos['key'][0] = tr('Invalid key')
            self.cert_logger.debug("Invalid key : %s" % error)

        # CA
        try:
            if isfile(self.CA_PATH):
                cert = load_cert(self.CA_PATH)
                infos['ca'][0] = unicode(cert.get_subject())
                infos['ca'][1] = unicode(cert.as_text())
        except Exception, error:
            infos['ca'][0] = tr('Invalid CA')
            self.cert_logger.debug("Invalid CA : %s" % error)

        # CRL
        try:
            if isfile(self.CRL_PATH):
                crl = load_crl(self.CRL_PATH)
                infos['crl'][0] = tr('CRL set')
                infos['crl'][1] = unicode(crl.as_text())
        except Exception, error:
            infos['crl'][0] = tr('Invalid CRL')
            self.cert_logger.debug("Invalid CRL : %s" % error)