Beispiel #1
0
def execute_store(cert_request, not_valid_before, not_valid_after):
    pub_key_client = PubKeyClient()

    key = get_keys_to_sign()
    cert = pub_key_client.process_csr(cert_request, key, not_valid_before, not_valid_after)

    crt_export, crt_bin, crt_sig, rem_sig, pub_key, \
        valid_from, valid_to = get_crt_export_bin_sig_rem_sig(cert, key, pub_key_client)

    batch_id, _ = pub_key_client.store_pub_key(pub_key, rem_sig, crt_sig, valid_from, valid_to)

    response = {'pub_key': pub_key,
                'crt_key': crt_export.decode('utf-8'),
                'batch_id': batch_id['batch_id']}

    return response
Beispiel #2
0
def execute_put(cert, key, key_export, name_to_save=None, passphrase=None):
    client = PubKeyClient()
    crt_export, crt_bin, crt_sig, rem_sig, pub_key, \
        valid_from, valid_to = get_crt_export_bin_sig_rem_sig(cert, key, client)

    try:
        saved_to = save_p12(cert, key, name_to_save, passphrase)
    except ValueError:
        return {'error': 'The file already exists in specified location'}, 409

    batch_id, _ = client.store_pub_key(pub_key, rem_sig, crt_sig, valid_from, valid_to)

    response = {'priv_key': key_export.decode('utf-8'),
                'pub_key': pub_key,
                'crt_key': crt_export.decode('utf-8'),
                'batch_id': batch_id['batch_id']}
    if saved_to:
        response['saved_to'] = saved_to

    return response