コード例 #1
0
def processCommandline():
    options = optionParse()

    _maxDays = daysTil18Jan2038()

    cert_expiration = getOption(options, 'cert_expiration')
    if cert_expiration:
        if cert_expiration < 1:
            raise CertExpTooShortException(
                "certificate expiration must be at least 1 day")
        if cert_expiration > _maxDays:
            raise CertExpTooLongException(
                "certificate expiration cannot exceed %s days "
                "(~%.2f years)\n" % (int(_maxDays), yearsTil18Jan2038()))

    country = getOption(options, 'set_country')
    if country is not None and (country == '' or len(country) != 2):
        raise InvalidCountryCodeException(
            "country code must be exactly two characters, such as 'US'")

    if options.quiet:
        options.verbose = -1
    if not options.verbose:
        options.verbose = 0

    return options
コード例 #2
0
ファイル: sslToolCli.py プロジェクト: mcalmer/spacewalk
def processCommandline():
    options = optionParse()

    _maxDays = daysTil18Jan2038()

    cert_expiration = getOption(options, 'cert_expiration')
    if cert_expiration:
        if cert_expiration < 1:
            raise CertExpTooShortException(
                    "certificate expiration must be at least 1 day")
        if cert_expiration > _maxDays:
            raise CertExpTooLongException(
                    "certificate expiration cannot exceed %s days "
                    "(~%.2f years)\n"
                    % (int(_maxDays), yearsTil18Jan2038()))

    country = getOption(options, 'set_country')
    if country is not None and (country == '' or len(country) != 2):
        raise InvalidCountryCodeException(
                "country code must be exactly two characters, such as 'US'")

    if options.quiet:
        options.verbose = -1
    if not options.verbose:
        options.verbose = 0

    return options
コード例 #3
0
def _main():
    """ main routine """

    options = processCommandline()

    legacyTreeFixup(DEFS)

    if getOption(options, 'check_key'):
        checkCaKey(getCAPassword(options), DEFS)

    if getOption(options, 'check_cert'):
        checkCaCert(DEFS)

    if getOption(options, 'gen_ca'):
        if getOption(options, 'key_only'):
            genPrivateCaKey(getCAPassword(options), DEFS,
                            options.verbose, options.force)
        elif getOption(options, 'cert_only'):
            genPublicCaCert_dependencies(getCAPassword(options), DEFS, options.force)
            genPublicCaCert(getCAPassword(options), DEFS,
                            options.verbose, options.force)
        elif getOption(options, 'rpm_only'):
            genCaRpm_dependencies(DEFS)
            genCaRpm(DEFS, options.verbose)
        else:
            genPrivateCaKey(getCAPassword(options), DEFS,
                            options.verbose, options.force)
            genPublicCaCert(getCAPassword(options), DEFS,
                            options.verbose, options.force)
            if not getOption(options, 'no_rpm'):
                genCaRpm(DEFS, options.verbose)

    if getOption(options, 'gen_server'):
        if getOption(options, 'key_only'):
            genServerKey(DEFS, options.verbose)
        elif getOption(options, 'cert_req_only'):
            genServerCertReq_dependencies(DEFS)
            genServerCertReq(DEFS, options.verbose)
        elif getOption(options, 'cert_only'):
            genServerCert_dependencies(getCAPassword(options, confirmYN=0), DEFS)
            genServerCert(getCAPassword(options, confirmYN=0), DEFS, options.verbose)
        elif getOption(options, 'rpm_only'):
            genServerRpm_dependencies(DEFS)
            genServerRpm(DEFS, options.verbose)
        else:
            genServer_dependencies(getCAPassword(options, confirmYN=0), DEFS)
            genServerKey(DEFS, options.verbose)
            genServerCertReq(DEFS, options.verbose)
            genServerCert(getCAPassword(options, confirmYN=0), DEFS, options.verbose)
            gen_jabberd_cert(DEFS)
            if not getOption(options, 'no_rpm'):
                genServerRpm(DEFS, options.verbose)
コード例 #4
0
ファイル: rhn_ssl_tool.py プロジェクト: mcalmer/spacewalk
def _main():
    """ main routine """

    options = processCommandline()

    legacyTreeFixup(DEFS)

    if getOption(options, 'check_key'):
        checkCaKey(getCAPassword(options), DEFS)

    if getOption(options, 'check_cert'):
        checkCaCert(DEFS)

    if getOption(options, 'gen_ca'):
        if getOption(options, 'key_only'):
            genPrivateCaKey(getCAPassword(options), DEFS,
                            options.verbose, options.force)
        elif getOption(options, 'cert_only'):
            genPublicCaCert_dependencies(getCAPassword(options), DEFS, options.force)
            genPublicCaCert(getCAPassword(options), DEFS,
                            options.verbose, options.force)
        elif getOption(options, 'rpm_only'):
            genCaRpm_dependencies(DEFS)
            genCaRpm(DEFS, options.verbose)
        else:
            genPrivateCaKey(getCAPassword(options), DEFS,
                            options.verbose, options.force)
            genPublicCaCert(getCAPassword(options), DEFS,
                            options.verbose, options.force)
            if not getOption(options, 'no_rpm'):
                genCaRpm(DEFS, options.verbose)

    if getOption(options, 'gen_server'):
        if getOption(options, 'key_only'):
            genServerKey(DEFS, options.verbose)
        elif getOption(options, 'cert_req_only'):
            genServerCertReq_dependencies(DEFS)
            genServerCertReq(DEFS, options.verbose)
        elif getOption(options, 'cert_only'):
            genServerCert_dependencies(getCAPassword(options, confirmYN=0), DEFS)
            genServerCert(getCAPassword(options, confirmYN=0), DEFS, options.verbose)
        elif getOption(options, 'rpm_only'):
            genServerRpm_dependencies(DEFS)
            genServerRpm(DEFS, options.verbose)
        else:
            genServer_dependencies(getCAPassword(options, confirmYN=0), DEFS)
            genServerKey(DEFS, options.verbose)
            genServerCertReq(DEFS, options.verbose)
            genServerCert(getCAPassword(options, confirmYN=0), DEFS, options.verbose)
            gen_jabberd_cert(DEFS)
            if not getOption(options, 'no_rpm'):
                genServerRpm(DEFS, options.verbose)