Example #1
0
def _update_dest(args):
    with app.app_context():
        dest = Destination.query.get(args.id)
        if not dest:
            print("There is no such destination {}".format(args.id))
            return
        if dest.user_id != 1:
            print("This destination does not belong to the admin")
            return

        pkey = None
        if args.pkey:
            with open(args.pkey, 'rb') as f:
                pkey = crypto.load_private_key(f.read())
        if dest.update(user_id=1,
                       host=args.host,
                       port=args.port,
                       user=args.user,
                       password=args.pwd,
                       ssh_priv_key=pkey,
                       ssh_priv_key_pass=args.pkeypass,
                       challengeDestinationPath=args.challengePath,
                       certDestinationPath=args.certPath,
                       exportFormat=args.exportFormat,
                       no_check=args.nocheck):

            print("Destination: {} updated".format(dest.id))
            print(dest.json)
        else:
            print(
                "Error updating destination with given data. Check hostname, password, private key"
            )
            print(dest.json)
Example #2
0
def _create_dest(args):
    pkey = None
    if args.pkey:
        with open(args.pkey, 'rb') as f:
            pkey = crypto.load_private_key(f.read())
    with app.app_context():
        dest = Destination(user_id=1,
                           host=args.host,
                           port=args.port,
                           user=args.user,
                           password=args.pwd,
                           ssh_priv_key=pkey,
                           ssh_priv_key_pass=args.pkeypass,
                           challengeDestinationPath=args.challengePath,
                           certDestinationPath=args.certPath,
                           exportFormat=args.exportFormat,
                           no_check=args.nocheck)
        if dest.create():
            print("Destination: {} created".format(dest.id))
            print(dest.json)
        else:
            print(
                "Error creating destination with given data. Check hostname, password, private key"
            )
            print(dest.json)
Example #3
0
def _issue(args):
    key = None
    if args.key_file:
        with open(args.key_file, 'rb') as f:
            key = crypto.load_private_key(f.read())
    csr = None
    if args.csr_file:
        with open(args.csr_file, 'rb') as f:
            key = crypto.load_csr(f.read())

    with app.app_context():
        ret, order_id = create_order(
            account_id=args.account,
            destination_id=args.destination,
            domains=args.domains,
            type=args.type,
            provider=args.provider,
            email=args.email,
            organization=args.organization,
            organizational_unit=args.organizational_unit,
            country=args.country,
            state=args.state,
            location=args.location,
            reissue=args.reissue,
            csr=csr,
            key=key)

    if ret:
        print("Order created with order id: {}".format(order_id))
    else:
        print("Order creation failed.")
Example #4
0
def _delete_dest(args):
    with app.app_context():
        dest = Destination.query.get(args.id)
        if not dest:
            print("There is no such destination {}".format(args.id))
            return
        if dest.user_id != 1:
            print("This destination does not belong to the admin")
            return
        dest = dest.delete()
        print("Destination {} deleted from database".format(dest.id))
Example #5
0
def _revoke(args):
    with app.app_context():
        certdb = Certificate.query.get(args.certificate)
        if not certdb:
            print("There is no such certificate {}".format(args.certificate))
            return

        order = Order.query.get(certdb.order_id)
        if not order:
            print("Order for this certificate not found")
            return

        revoke_certificate(order.account_id, certdb.id)
Example #6
0
def _register(args):
    key = None
    if args.key_file:
        with open(args.key_file, 'rb') as f:
            key = crypto.load_private_key(f.read())

    with app.app_context():
        ret, act_id = register(user_id=1,
                               email=args.email,
                               server=args.server,
                               rsa_key=key,
                               organization=args.organization,
                               organizational_unit=args.organizational_unit,
                               country=args.country,
                               state=args.state,
                               location=args.location)

    if ret:
        print("Account created with account id: {}".format(act_id))
        print("Pass this account id for issue, revoke, etc...")
    else:
        print("Account with same email exists: account id: {}".format(act_id))