def find_unsigned_certificates(app_config):
    cert_info = collections.OrderedDict()
    for filename, (uid,) in sorted(glob2.iglob(
            app_config.unsigned_certs_file_pattern, with_matches=True)):
        with open(filename) as cert_file:
            cert_raw = cert_file.read()
            cert_json = json.loads(cert_raw)
            certificate = CertificateMetadata(config=app_config,
                                              uid=uid,
                                              public_key=cert_json['recipient']['publicKey'])
            cert_info[uid] = certificate

    return cert_info
def find_unsigned_certificates(app_config):
    cert_info = {}
    for filename, (uid, ) in glob2.iglob(
            app_config.unsigned_certs_file_pattern, with_matches=True):
        with open(filename) as cert_file:
            cert_raw = cert_file.read()
            cert_json = json.loads(cert_raw)
            certificate_metadata = CertificateMetadata(
                app_config, uid, cert_json['recipient']['givenName'] + ' ' +
                cert_json['recipient']['familyName'],
                cert_json['recipient']['pubkey'])
            cert_info[uid] = certificate_metadata

    return cert_info
Exemple #3
0
    def test_sign_cert(self):
        cert_metadata = CertificateMetadata('test/unsigned.json',
                                            'test/signed.json')
        cert_info = {'123452': cert_metadata}

        with patch('cert_issuer.sign_certificates.open', mock_open(read_data='{"assertion":{"uid": "123"}}'),
                   create=True) as m, \
                patch('cert_issuer.sign_certificates.SignMessage', return_value=b'123'), \
                patch('cert_issuer.helpers.import_key', return_value='tcKK1A9Si73zG5ZFnA6XYyhAcb1BNrMVyG'):
            sign_certificates.sign_certs(cert_info)
            handle = m()
            handle.write.assert_called_once_with(
                bytes('{"assertion": {"uid": "123"}, "signature": "123"}',
                      'utf-8'))
Exemple #4
0
    def test_hash_certs(self):

        cert_metadata = CertificateMetadata(MagicMock(), 'someuid',
                                            'some_name', 'somekey')
        cert_info = {'someuid': cert_metadata}
        with patch('cert_issuer.create_certificates.open',
                   mock_open(read_data='bibble'.encode('utf-8')),
                   create=True) as m:
            create_certificates.hash_certs(cert_info)
            handle = m()
            handle.read.assert_called_once()
            handle.write.assert_called_once_with(
                b'\xf1\x93\x13\xb9D\x94\x9e\x16\xb8\xf8\x12,\x05`u\x13\xa2\xa8\x1f\xfc\xd4\x87\x10\xe2\xd8\x98\xc1\x9f\x17\xa0\x83\xfa'
            )
Exemple #5
0
def find_signed_certificates(app_config):
    cert_info = collections.OrderedDict()
    for filename, (uid, ) in sorted(
            glob2.iglob(app_config.signed_certs_file_pattern,
                        with_matches=True)):
        with open(filename) as cert_file:
            cert_raw = cert_file.read()
            cert_json = json.loads(cert_raw)
            revocation_key = None
            if 'revocationKey' in cert_json['recipient']:
                revocation_key = cert_json['recipient']['revocationKey']
            certificate_metadata = CertificateMetadata(
                app_config, uid, cert_json['recipient']['publicKey'],
                revocation_key)
            cert_info[uid] = certificate_metadata

    return cert_info