コード例 #1
0
def main():
    # passphrase = getpass.getpass('Please enter CA key Passphrase')
    passphrase = 'fred'
    if os.path.isfile('./ssl/ca_key.pem') is False and os.path.isfile(
            './ssl/ca_cert.pem') is False:
        ca_key = cry.create_key()
        cry.save_key(ca_key, './ssl/ca_key.pem', passphrase)
        ca_csr = cry.create_csr(ca_key,
                                country_name='GB',
                                locality='London',
                                organisation='Tactical Networks',
                                common_name='CA.tactical-net.co.uk',
                                is_ca=True)
        ca_cert = cry.create_cert(ca_key,
                                  csr=ca_csr,
                                  lifetime=3650,
                                  is_ca=True)
        cry.save_cert(ca_cert, './ssl/ca_cert.pem')
    else:
        ca_key = cry.load_key('./ssl/ca_key.pem', passphrase)
        ca_cert = cry.load_cert('./ssl/ca_cert.pem')

    print_title("Playbook to configure the network")
    nr = InitNornir(config_file='config.yaml', dry_run=False)
    # result = nr.run(task=disable_api, name='Disable API Task')
    # print_result(result, severity_level=logging.INFO)
    # nr = nr.filter(platform='nxos')
    result = nr.run(task=task_wrangler,
                    name='Main Task Wrangler',
                    ca_key=ca_key,
                    ca_cert=ca_cert)
    print_result(result, severity_level=logging.INFO)
コード例 #2
0
def user_key():
    key = cry.create_key(2048)
    return key
コード例 #3
0
def test_create_self_signed_cert_no_parameters(cert_parameters):
    key = cry.create_key(2048)
    cert = cry.create_cert(key)
    assert isinstance(cert, x509.Certificate)
    assert cert.extensions.get_extension_for_class(x509.BasicConstraints).value.ca is False
コード例 #4
0
def ra_key():
    key = cry.create_key(2048)
    return key
コード例 #5
0
def test_create_key():
    key = cry.create_key(2048)
    assert isinstance(key, rsa.RSAPrivateKey)