当前位置: 首页>>代码示例>>Python>>正文


Python CertUtils.generate_cert_generic方法代码示例

本文整理汇总了Python中CertUtils.generate_cert_generic方法的典型用法代码示例。如果您正苦于以下问题:Python CertUtils.generate_cert_generic方法的具体用法?Python CertUtils.generate_cert_generic怎么用?Python CertUtils.generate_cert_generic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CertUtils的用法示例。


在下文中一共展示了CertUtils.generate_cert_generic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs():
    key_type = "rsa"
    ca_ext = CA_basic_constraints + CA_full_ku + subject_key_ident + CA_eku
    ee_ext_text = EE_basic_constraints + authority_key_ident
    [ca_key, ca_cert] = CertUtils.generate_cert_generic(db, srcdir, 1, key_type, "ca", ca_ext)

    [int_key, int_cert] = CertUtils.generate_cert_generic(db, srcdir, 103, key_type, "int", ca_ext, ca_key, ca_cert)

    # now the ee
    CertUtils.generate_cert_generic(db, srcdir, 100, key_type, "ee", ee_ext_text, int_key, int_cert)
开发者ID:c0mmandCS,项目名称:Waterfox,代码行数:12,代码来源:generate.py

示例2: generate_family

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_family(db_dir, dst_dir, ca_key, ca_cert, base_name):
    key_type = 'rsa'
    ee_ext_base = EE_basic_constraints + authority_key_ident;
    CertUtils.generate_cert_generic(db,
                                    srcdir,
                                    10,
                                    key_type,
                                    'cn-a.pinning2.example.com-'+ base_name,
                                    ee_ext_base,
                                    ca_key,
                                    ca_cert,
                                    '/CN=a.pinning2.example.com')

    CertUtils.generate_cert_generic(db,
                                    srcdir,
                                    11,
                                    key_type,
                                    'cn-x.a.pinning2.example.com-'+ base_name,
                                    ee_ext_base,
                                    ca_key,
                                    ca_cert,
                                    '/CN=x.a.pinning2.example.com')

    alt_name_ext = 'subjectAltName =DNS:a.pinning2.example.com'
    CertUtils.generate_cert_generic(db,
                                    srcdir,
                                    12,
                                    key_type,
                                    'cn-www.example.com-alt-a.pinning2.example-'+ base_name,
                                    ee_ext_base + alt_name_ext,
                                    ca_key,
                                    ca_cert,
                                    '/CN=www.example.com')

    CertUtils.generate_cert_generic(db,
                                    srcdir,
                                    13,
                                    key_type,
                                    'cn-b.pinning2.example.com-'+ base_name,
                                    ee_ext_base,
                                    ca_key,
                                    ca_cert,
                                    '/CN=b.pinning2.example.com')

    CertUtils.generate_cert_generic(db,
                                    srcdir,
                                    14,
                                    key_type,
                                    'cn-x.b.pinning2.example.com-'+ base_name,
                                    ee_ext_base,
                                    ca_key,
                                    ca_cert,
                                    '/CN=x.b.pinning2.example.com')
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:55,代码来源:generate.py

示例3: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs():

    CertUtils.init_dsa(db)
    ee_ext_text = EE_basic_constraints + EE_full_ku
    for name, key_type in pk_name.iteritems():
        ca_name = "ca-" + name
        [ca_key, ca_cert] = CertUtils.generate_cert_generic(db,
                                                            srcdir,
                                                            random.randint(100,4000000),
                                                            key_type,
                                                            ca_name,
                                                            CA_basic_constraints + CA_min_ku)

        [valid_int_key, valid_int_cert, ee_key, ee_cert] =  (
            CertUtils.generate_int_and_ee(db,
                                          srcdir,
                                          ca_key,
                                          ca_cert,
                                          name + "-valid",
                                          CA_basic_constraints,
                                          ee_ext_text,
                                          key_type) )

        [int_key, int_cert] = CertUtils.generate_cert_generic(db,
                                                            srcdir,
                                                            random.randint(100,4000000),
                                                            key_type,
                                                            "int-" + name + "-tampered",
                                                            ee_ext_text,
                                                            ca_key,
                                                            ca_cert)


        [ee_key, ee_cert] = CertUtils.generate_cert_generic(db,
                                                            srcdir,
                                                            random.randint(100,4000000),
                                                            key_type,
                                                            name + "-tampered-int-valid-ee",
                                                            ee_ext_text,
                                                            int_key,
                                                            int_cert)
        #only tamper after ee has been generated
        tamper_cert(int_cert);

        [ee_key, ee_cert] = CertUtils.generate_cert_generic(db,
                                                            srcdir,
                                                            random.randint(100,4000000),
                                                            key_type,
                                                            name + "-valid-int-tampered-ee",
                                                            ee_ext_text,
                                                            valid_int_key,
                                                            valid_int_cert)
        tamper_cert(ee_cert);
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:55,代码来源:generate.py

示例4: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs(do_cert_generation):
    ca_name = "ca"
    if do_cert_generation:
        [ca_key, ca_cert] = CertUtils.generate_cert_generic(
                              db, srcdir, 1, key_type, ca_name,
                              CA_basic_constraints)
    ee_ext_text = EE_basic_constraints + EE_full_ku

    # now we do it again for valid basic constraints but strange eku/ku at the
    # intermediate layer
    eku_dict = generate_test_eku()
    print eku_dict
    for eku_name in (sorted(eku_dict.keys())):
        # Divide the tests into multiple files to avoid time outs
        js_outfile = open("../test_cert_eku-" + eku_name + ".js", "w")
        js_outfile.write(js_file_header)

        # generate int
        int_name = "int-EKU-" + eku_name
        int_serial = random.randint(100, 40000000)
        eku_text = "extendedKeyUsage = " + eku_dict[eku_name]
        if (eku_name == "NONE"):
            eku_text = ""
        int_ext_text = CA_basic_constraints + CA_full_ku + eku_text
        if do_cert_generation:
            [int_key, int_cert] = CertUtils.generate_cert_generic(
                                    db, srcdir, int_serial, key_type, int_name,
                                    int_ext_text, ca_key, ca_cert)
        js_outfile.write("\n")
        js_outfile.write(gen_int_js_output(int_name))

        for ee_eku_name in (sorted(eku_dict.keys())):
            ee_base_name = "ee-EKU-" + ee_eku_name
            ee_name = ee_base_name + "-" + int_name
            ee_serial = random.randint(100, 40000000)
            ee_eku = "extendedKeyUsage = critical," + eku_dict[ee_eku_name]
            if (ee_eku_name == "NONE"):
                ee_eku = ""
            ee_ext_text = EE_basic_constraints + EE_full_ku + ee_eku
            if do_cert_generation:
                [ee_key, ee_cert] = CertUtils.generate_cert_generic(
                                      db, srcdir, ee_serial, key_type, ee_name,
                                      ee_ext_text, int_key, int_cert)
            for cert_usage in (cert_usages):
                js_outfile.write(gen_ee_js_output(int_name, ee_base_name,
                                 cert_usage, ee_name))

        js_outfile.write(js_file_footer)
        js_outfile.close()
开发者ID:itcms,项目名称:tor-browser,代码行数:51,代码来源:generate.py

示例5: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs():
    init_nss_db()
    ca_cert = 'evroot.der'
    ca_key = 'evroot.key'
    prefix = "ev-valid"
    key_type = 'rsa'
    ee_ext_text = (EE_basic_constraints + EE_full_ku + Server_eku +
                   authority_key_ident + aia_prefix + prefix + aia_suffix +
                   endentity_crl + mozilla_testing_ev_policy)
    int_ext_text = (CA_basic_constraints + EE_full_ku + CA_eku +
                    authority_key_ident + subject_key_ident +
                    aia_prefix + "int-" + prefix + aia_suffix +
                    intermediate_crl + mozilla_testing_ev_policy)
    [int_key, int_cert, ee_key, ee_cert] = CertUtils.generate_int_and_ee(db,
                                             srcdir,
                                             ca_key,
                                             ca_cert,
                                             prefix,
                                             int_ext_text,
                                             ee_ext_text,
                                             key_type)
    pk12file = CertUtils.generate_pkcs12(db, srcdir, int_cert, int_key,
                                         "int-" + prefix)
    import_cert_and_pkcs12(int_cert, pk12file, "int-" + prefix, ",,")
    import_untrusted_cert(ee_cert, prefix)
    [bad_ca_key, bad_ca_cert] = CertUtils.generate_cert_generic( db,
                                      srcdir,
                                      1,
                                      'rsa',
                                      'non-evroot-ca',
                                      CA_basic_constraints + EE_full_ku +
                                        authority_key_ident)
    pk12file =  CertUtils.generate_pkcs12(db, srcdir, bad_ca_cert, bad_ca_key,
                                          "non-evroot-ca")
    import_cert_and_pkcs12(bad_ca_cert, pk12file, "non-evroot-ca", "C,C,C")
    prefix = "non-ev-root"
    ee_ext_text = (EE_basic_constraints + EE_full_ku + Server_eku +
                  authority_key_ident + aia_prefix + prefix  + aia_suffix +
                  endentity_crl + mozilla_testing_ev_policy)
    int_ext_text = (CA_basic_constraints + EE_full_ku + CA_eku +
                   authority_key_ident + aia_prefix + "int-" + prefix +
                   aia_suffix + intermediate_crl + subject_key_ident +
                   mozilla_testing_ev_policy)
    [int_key, int_cert, ee_key, ee_cert] = CertUtils.generate_int_and_ee(db,
                                      srcdir,
                                      bad_ca_key,
                                      bad_ca_cert,
                                      prefix,
                                      int_ext_text,
                                      ee_ext_text,
                                      key_type)
    pk12file =  CertUtils.generate_pkcs12(db, srcdir, int_cert, int_key,
                                          "int-" + prefix)
    import_cert_and_pkcs12(int_cert, pk12file, "int-" + prefix, ",,")
    import_untrusted_cert(ee_cert, prefix)
开发者ID:galexcode,项目名称:mozilla-central,代码行数:57,代码来源:generate.py

示例6: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs():
    key_type = 'rsa'
    ca_ext = CA_basic_constraints + CA_full_ku + subject_key_ident + CA_eku;
    ee_ext_text = (EE_basic_constraints + authority_key_ident)
    [ca_key, ca_cert] = CertUtils.generate_cert_generic(db,
                                                        srcdir,
                                                        1,
                                                        key_type,
                                                        'ca',
                                                        ca_ext)
    CertUtils.generate_cert_generic(db,
                                    srcdir,
                                    100,
                                    key_type,
                                    'ee',
                                    ee_ext_text,
                                    ca_key,
                                    ca_cert)

    shutil.copy(ca_cert, srcdir + "/" + "ca-1.der")
    self_sign_csr(db, srcdir, db + "/ca.csr", ca_key, 2, ca_ext, "ca-2")
    os.remove(ca_cert);
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:24,代码来源:generate.py

示例7: generate_int_and_ee2

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_int_and_ee2(ca_key, ca_cert, suffix, int_ext_text, ee_ext_text):
    int_name = "int-" + suffix;
    ee_name  = "ee-int-" + suffix;
    int_serial = random.randint(100, 40000000);
    ee_serial = random.randint(100, 40000000);
    [int_key, int_cert] = CertUtils.generate_cert_generic(db,
                                                        srcdir,
                                                        int_serial,
                                                        key_type,
                                                        int_name,
                                                        int_ext_text,
                                                        ca_key,
                                                        ca_cert);
    [ee_key, ee_cert] = CertUtils.generate_cert_generic(db,
                                                        srcdir,
                                                        ee_serial,
                                                        key_type,
                                                        ee_name,
                                                        ee_ext_text,
                                                        int_key,
                                                        int_cert);
    return [int_key, int_cert, ee_key, ee_cert]
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:24,代码来源:generate.py

示例8: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs():
    js_outfile = open("../test_cert_eku.js", 'w');
    ca_name = "ca"
    [ca_key, ca_cert ] = CertUtils.generate_cert_generic(db,
                                                        srcdir,
                                                        1,
                                                        key_type,
                                                        ca_name,
                                                        CA_basic_constraints)
    ee_ext_text = EE_basic_constraints + EE_full_ku

    js_outfile.write(js_file_header);

    # now we do it again for valid basic constraints but strange eku/ku at the
    # intermediate layer
    eku_dict = generate_test_eku();
    print eku_dict
    for eku_name in (sorted(eku_dict.keys())):
        #generate int
        int_name = "int-EKU-" + eku_name;
        int_serial = random.randint(100, 40000000);
        eku_text = "extendedKeyUsage = " + eku_dict[eku_name]
        if (eku_name == "NONE"):
            eku_text = ""
        int_ext_text = CA_basic_constraints + CA_full_ku + eku_text
        [int_key, int_cert] = CertUtils.generate_cert_generic(db,
                                                            srcdir,
                                                        int_serial,
                                                        key_type,
                                                        int_name,
                                                        int_ext_text,
                                                        ca_key,
                                                        ca_cert);
        if ("NS" in int_name) or ("SA" in int_name) or ("NONE" in int_name):
            if ("OS" not in int_name):
                js_outfile.write("\n  check_ok_ca(load_cert('"+ int_name + "', ',,'));\n")
            else:
                js_outfile.write("\n  load_cert('"+ int_name +"', ',,');\n")
        else:
            if ( "CA" in int_name):
                # classic allows a cert to be considered CA even if it only
                # asserts the ClientAuth EKU, here we have a failure of
                # expression. Insanity is more explicit and requires
                # the ServerAuth EKU
                js_outfile.write("\n  check_cert_err_generic(load_cert('"+
                                 int_name +"', ',,'), useMozillaPKIX ? -1 : " +
                                 "0, certificateUsageSSLCA) ;\n")
            else:
                js_outfile.write("\n  check_cert_err_generic(load_cert('"+
                                 int_name +"', ',,'), useMozillaPKIX ? -1 : " +
                                 "-1, certificateUsageSSLCA) ;\n")

        for ee_eku_name  in (sorted(eku_dict.keys())):
            ee_base_name = "ee-EKU-" + ee_eku_name;
            ee_name = ee_base_name + "-" + int_name
            ee_serial = random.randint(100, 40000000);
            ee_eku = "extendedKeyUsage = critical," + eku_dict[ee_eku_name]
            if (ee_eku_name == "NONE"):
                ee_eku = ""
            ee_ext_text =  EE_basic_constraints + EE_full_ku + ee_eku
            [ee_key, ee_cert] = CertUtils.generate_cert_generic(db,
                                                            srcdir,
                                                        ee_serial,
                                                        key_type,
                                                        ee_name,
                                                        ee_ext_text,
                                                        int_key,
                                                        int_cert)
            for cert_usage in (cert_usages):
                js_outfile.write(gen_js_output(int_name, ee_base_name,
                                 cert_usage, ee_name))

    js_outfile.write(js_file_footer)
    js_outfile.close()
开发者ID:elefant,项目名称:gecko-dev,代码行数:76,代码来源:generate.py

示例9: Testing

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
CA_basic_constraints = "basicConstraints = critical, CA:TRUE\n"
CA_min_ku = "keyUsage = critical, digitalSignature, keyCertSign, cRLSign\n"
subject_key_ident = "subjectKeyIdentifier = hash\n"

cert_name = 'evroot'
ext_text = CA_basic_constraints + CA_min_ku + subject_key_ident
subject_string = ('/C=US/ST=CA/L=Mountain View' +
                  '/O=Mozilla - EV debug test CA/OU=Security Engineering' +
                  '/CN=XPCShell EV Testing (untrustworthy) CA')

# The db_dir argument of generate_cert_generic() is also set to dest_dir as
# the .key file generated is needed by other certs.
[ca_key, ca_cert] = CertUtils.generate_cert_generic(
    dest_dir,
    dest_dir,
    random.randint(100, 40000000),
    'rsa',
    cert_name,
    ext_text,
    subject_string = subject_string)

CertUtils.generate_pkcs12(db, dest_dir, ca_cert, ca_key, cert_name)

# Print a blank line and the information needed to enable EV for the root
# generated by this script.
print
CertUtils.print_cert_info_for_ev(ca_cert)
print ('You now MUST update the compiled test EV root information to match ' +
       'the EV root information printed above. In addition, certs that chain ' +
       'up to this root in other folders will also need to be regenerated.' )
开发者ID:marshall,项目名称:gecko-dev,代码行数:32,代码来源:ev_root_generate.py

示例10: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs(key_type, bad_key_size, ok_key_size):
    if key_type == 'dsa':
        CertUtils.init_dsa(db_dir, dsaBad_param_filename, bad_key_size)
        CertUtils.init_dsa(db_dir, dsaOK_param_filename, ok_key_size)

    # OK Chain
    [caOK_key, caOK_cert] = CertUtils.generate_cert_generic(
                                db_dir,
                                srcdir,
                                random.randint(100, 40000000),
                                key_type,
                                key_type + '-caOK',
                                ca_ext_text,
                                dsa_param_filename = dsaOK_param_filename,
                                key_size = ok_key_size)

    [intOK_key, intOK_cert] = CertUtils.generate_cert_generic(
                                  db_dir,
                                  srcdir,
                                  random.randint(100, 40000000),
                                  key_type,
                                  key_type + '-intOK-caOK',
                                  ca_ext_text,
                                  caOK_key,
                                  caOK_cert,
                                  dsa_param_filename = dsaOK_param_filename,
                                  key_size = ok_key_size)

    CertUtils.generate_cert_generic(db_dir,
                                    srcdir,
                                    random.randint(100, 40000000),
                                    key_type,
                                    key_type + '-eeOK-intOK-caOK',
                                    ee_ext_text,
                                    intOK_key,
                                    intOK_cert,
                                    dsa_param_filename = dsaOK_param_filename,
                                    key_size = ok_key_size)

    # Bad CA
    [caBad_key, caBad_cert] = CertUtils.generate_cert_generic(
                                  db_dir,
                                  srcdir,
                                  random.randint(100, 40000000),
                                  key_type,
                                  key_type + '-caBad',
                                  ca_ext_text,
                                  dsa_param_filename = dsaBad_param_filename,
                                  key_size = bad_key_size)

    [int_key, int_cert] = CertUtils.generate_cert_generic(
                              db_dir,
                              srcdir,
                              random.randint(100, 40000000),
                              key_type,
                              key_type + '-intOK-caBad',
                              ca_ext_text,
                              caBad_key,
                              caBad_cert,
                              dsa_param_filename = dsaOK_param_filename,
                              key_size = ok_key_size)

    CertUtils.generate_cert_generic(db_dir,
                                    srcdir,
                                    random.randint(100, 40000000),
                                    key_type,
                                    key_type + '-eeOK-intOK-caBad',
                                    ee_ext_text,
                                    int_key,
                                    int_cert,
                                    dsa_param_filename = dsaOK_param_filename,
                                    key_size = ok_key_size)

    # Bad Intermediate
    [intBad_key, intBad_cert] = CertUtils.generate_cert_generic(
                                    db_dir,
                                    srcdir,
                                    random.randint(100, 40000000),
                                    key_type,
                                    key_type + '-intBad-caOK',
                                    ca_ext_text,
                                    caOK_key,
                                    caOK_cert,
                                    dsa_param_filename = dsaBad_param_filename,
                                    key_size = bad_key_size)

    CertUtils.generate_cert_generic(db_dir,
                                    srcdir,
                                    random.randint(100, 40000000),
                                    key_type,
                                    key_type + '-eeOK-intBad-caOK',
                                    ee_ext_text,
                                    intBad_key,
                                    intBad_cert,
                                    dsa_param_filename = dsaOK_param_filename,
                                    key_size = ok_key_size)

    # Bad End Entity
    CertUtils.generate_cert_generic(db_dir,
                                    srcdir,
#.........这里部分代码省略.........
开发者ID:L2-D2,项目名称:gecko-dev,代码行数:103,代码来源:generate.py

示例11: generate_certs

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_certs():
    init_nss_db()
    ca_cert = 'evroot.der'
    ca_key = 'evroot.key'
    prefix = "ev-valid"
    key_type = 'rsa'
    ee_ext_text = (aia_prefix + prefix + aia_suffix +
                   endentity_crl + mozilla_testing_ev_policy)
    int_ext_text = (CA_extensions + aia_prefix + "int-" + prefix + aia_suffix +
                    intermediate_crl + mozilla_testing_ev_policy)
    [int_key, int_cert, ee_key, ee_cert] = CertUtils.generate_int_and_ee(db,
                                             srcdir,
                                             ca_key,
                                             ca_cert,
                                             prefix,
                                             int_ext_text,
                                             ee_ext_text,
                                             key_type)
    pk12file = CertUtils.generate_pkcs12(db, srcdir, int_cert, int_key,
                                         "int-" + prefix)
    import_cert_and_pkcs12(int_cert, pk12file, "int-" + prefix, ",,")
    import_untrusted_cert(ee_cert, prefix)

    # now we generate an end entity cert with an AIA with no OCSP URL
    no_ocsp_url_ext_aia = ("authorityInfoAccess =" +
                           "caIssuers;URI:http://www.example.com/ca.html\n");
    [no_ocsp_key, no_ocsp_cert] =  CertUtils.generate_cert_generic(db,
                                      srcdir,
                                      random.randint(100, 40000000),
                                      key_type,
                                      'no-ocsp-url-cert',
                                      no_ocsp_url_ext_aia + endentity_crl +
                                      mozilla_testing_ev_policy,
                                      int_key, int_cert);
    import_untrusted_cert(no_ocsp_cert, 'no-ocsp-url-cert');

    # add an ev cert whose intermediate has a anypolicy oid
    prefix = "ev-valid-anypolicy-int"
    ee_ext_text = (aia_prefix + prefix + aia_suffix +
                   endentity_crl + mozilla_testing_ev_policy)
    int_ext_text = (CA_extensions + aia_prefix + "int-" + prefix + aia_suffix +
                    intermediate_crl + anypolicy_policy)

    [int_key, int_cert, ee_key, ee_cert] = CertUtils.generate_int_and_ee(db,
                                             srcdir,
                                             ca_key,
                                             ca_cert,
                                             prefix,
                                             int_ext_text,
                                             ee_ext_text,
                                             key_type)
    pk12file = CertUtils.generate_pkcs12(db, srcdir, int_cert, int_key,
                                         "int-" + prefix)
    import_cert_and_pkcs12(int_cert, pk12file, "int-" + prefix, ",,")
    import_untrusted_cert(ee_cert, prefix)


    [bad_ca_key, bad_ca_cert] = CertUtils.generate_cert_generic( db,
                                      srcdir,
                                      1,
                                      'rsa',
                                      'non-evroot-ca',
                                      CA_extensions)
    pk12file =  CertUtils.generate_pkcs12(db, srcdir, bad_ca_cert, bad_ca_key,
                                          "non-evroot-ca")
    import_cert_and_pkcs12(bad_ca_cert, pk12file, "non-evroot-ca", "C,C,C")
    prefix = "non-ev-root"
    ee_ext_text = (aia_prefix + prefix  + aia_suffix +
                   endentity_crl + mozilla_testing_ev_policy)
    int_ext_text = (CA_extensions + aia_prefix + "int-" + prefix + aia_suffix +
                    intermediate_crl + mozilla_testing_ev_policy)
    [int_key, int_cert, ee_key, ee_cert] = CertUtils.generate_int_and_ee(db,
                                      srcdir,
                                      bad_ca_key,
                                      bad_ca_cert,
                                      prefix,
                                      int_ext_text,
                                      ee_ext_text,
                                      key_type)
    pk12file =  CertUtils.generate_pkcs12(db, srcdir, int_cert, int_key,
                                          "int-" + prefix)
    import_cert_and_pkcs12(int_cert, pk12file, "int-" + prefix, ",,")
    import_untrusted_cert(ee_cert, prefix)
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:85,代码来源:generate.py

示例12:

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import tempfile, os, sys, random

libpath = os.path.abspath("../psm_common_py")
sys.path.append(libpath)

import CertUtils

dest_dir = os.getcwd()
db = tempfile.mkdtemp()

serial = random.randint(100, 40000000)
name = "client-cert"
[key, cert] = CertUtils.generate_cert_generic(db, dest_dir, serial, "rsa",
                                              name, "")
CertUtils.generate_pkcs12(db, dest_dir, cert, key, name)

# Print a blank line and the fingerprint of the cert that ClientAuthServer.cpp
# should be modified with.
print
CertUtils.print_cert_info(cert)
print ('You now MUST update the fingerprint in ClientAuthServer.cpp to match ' +
       'the fingerprint printed above.')

# Remove unnecessary .der file
os.remove(dest_dir + "/" + name + ".der")
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:31,代码来源:generate.py

示例13: generate_and_maybe_import_cert

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_and_maybe_import_cert(
    key_type,
    cert_name_prefix,
    cert_name_suffix,
    base_ext_text,
    signer_key_filename,
    signer_cert_filename,
    key_size,
    generate_ev,
):
    """
    Generates a certificate and imports it into the NSS DB if appropriate.
    If an equivalent certificate has already been generated, it is reused.

    Arguments:
      key_type -- the type of key generated: potential values: 'rsa', or any of
                  the curves found by 'openssl ecparam -list_curves'
      cert_name_prefix -- prefix of the generated cert name
      cert_name_suffix -- suffix of the generated cert name
      base_ext_text -- the base text for the x509 extensions to be added to the
                       certificate (extra extensions will be added if generating
                       an EV cert)
      signer_key_filename -- the filename of the key from which the cert will
                             be signed. If an empty string is passed in the cert
                             will be self signed (think CA roots).
      signer_cert_filename -- the filename of the signer cert that will sign the
                              certificate being generated. Ignored if an empty
                              string is passed in for signer_key_filename.
                              Must be in DER format.
      key_size -- public key size for RSA certs
      generate_ev -- whether an EV cert should be generated

    Output:
      cert_name -- the resultant (nick)name of the certificate
      key_filename -- the filename of the key file (PEM format)
      cert_filename -- the filename of the certificate (DER format)
    """
    cert_name = cert_name_prefix + "_" + key_type + "_" + key_size

    # If the suffix is not the empty string, add a hyphen for visual separation
    if cert_name_suffix:
        cert_name += "-" + cert_name_suffix

    ev_ext_text = ""
    subject_string = "/CN=XPCShell Key Size Testing %s %s-bit" % (key_type, key_size)
    if generate_ev:
        cert_name = "ev_" + cert_name
        ev_ext_text = aia_prefix + cert_name + aia_suffix + mozilla_testing_ev_policy
        subject_string += " (EV)"

    # Use the organization field to store the cert nickname for easier debugging
    subject_string += "/O=" + cert_name

    # Reuse the existing RSA EV root
    if (
        generate_ev
        and key_type == "rsa"
        and signer_key_filename == ""
        and signer_cert_filename == ""
        and key_size == "2048"
    ):
        cert_name = "evroot"
        key_filename = "../test_ev_certs/evroot.key"
        cert_filename = "../test_ev_certs/evroot.der"
        CertUtils.import_cert_and_pkcs12(srcdir, cert_filename, "../test_ev_certs/evroot.p12", cert_name, ",,")
        return [cert_name, key_filename, cert_filename]

    # Don't regenerate a previously generated cert
    for cert in generated_certs:
        if cert_name == cert[0]:
            return cert

    [key_filename, cert_filename] = CertUtils.generate_cert_generic(
        db_dir,
        srcdir,
        random.randint(100, 40000000),
        key_type,
        cert_name,
        base_ext_text + ev_ext_text,
        signer_key_filename,
        signer_cert_filename,
        subject_string,
        key_size,
    )
    generated_certs.append([cert_name, key_filename, cert_filename])

    if generate_ev:
        # The dest_dir argument of generate_pkcs12() is also set to db_dir as
        # the .p12 files do not need to be kept once they have been imported.
        pkcs12_filename = CertUtils.generate_pkcs12(db_dir, db_dir, cert_filename, key_filename, cert_name)
        CertUtils.import_cert_and_pkcs12(srcdir, cert_filename, pkcs12_filename, cert_name, ",,")

        if not signer_key_filename:
            generated_ev_root_filenames.append(cert_filename)

    return [cert_name, key_filename, cert_filename]
开发者ID:Acidburn0zzz,项目名称:tor-browser,代码行数:98,代码来源:generate.py

示例14: generate_and_import_cert

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_and_import_cert(cert_name_prefix, cert_name_suffix,
                             base_ext_text, signer_key_filename,
                             signer_cert_filename, validity_in_months):
    """
    Generates a certificate and imports it into the NSS DB.

    Arguments:
        cert_name_prefix - prefix of the generated cert name
        cert_name_suffix - suffix of the generated cert name
        base_ext_text - the base text for the x509 extensions to be
                        added to the certificate (extra extensions will
                        be added if generating an EV cert)
        signer_key_filename - the filename of the key from which the
                              cert will be signed. If an empty string is
                              passed in the cert will be self signed
                              (think CA roots).
        signer_cert_filename - the filename of the signer cert that will
                               sign the certificate being generated.
                               Ignored if an empty string is passed in
                               for signer_key_filename.
                               Must be in DER format.
        validity_in_months - the number of months the cert should be
                             valid for.

    Output:
      cert_name - the resultant (nick)name of the certificate
      key_filename - the filename of the key file (PEM format)
      cert_filename - the filename of the certificate (DER format)
    """
    cert_name = 'ev_%s_%u_months' % (cert_name_prefix, validity_in_months)

    # If the suffix is not the empty string, add a hyphen for visual
    # separation
    if cert_name_suffix:
        cert_name += '-' + cert_name_suffix

    subject_string = '/CN=%s' % cert_name
    ev_ext_text = (CertUtils.aia_prefix + cert_name + CertUtils.aia_suffix +
                   CertUtils.mozilla_testing_ev_policy)

    # Reuse the existing RSA EV root
    if (signer_key_filename == '' and signer_cert_filename == ''):
        cert_name = 'evroot'
        key_filename = '../test_ev_certs/evroot.key'
        cert_filename = '../test_ev_certs/evroot.der'
        CertUtils.import_cert_and_pkcs12(src_dir, cert_filename,
                                         '../test_ev_certs/evroot.p12',
                                         cert_name, ',,')
        return [cert_name, key_filename, cert_filename]

    # Don't regenerate a previously generated cert
    for cert in generated_ev_certs:
        if cert_name == cert[0]:
            return cert

    validity_years = math.floor(validity_in_months / 12)
    validity_months = validity_in_months % 12
    [key_filename, cert_filename] = CertUtils.generate_cert_generic(
        temp_dir,
        src_dir,
        random.randint(100, 40000000),
        'rsa',
        cert_name,
        base_ext_text + ev_ext_text,
        signer_key_filename,
        signer_cert_filename,
        subject_string,
        validity_in_days = validity_years * 365 + validity_months * 31)
    generated_ev_certs.append([cert_name, key_filename, cert_filename])

    # The dest_dir argument of generate_pkcs12() is also set to temp_dir
    # as the .p12 files do not need to be kept once they have been
    # imported.
    pkcs12_filename = CertUtils.generate_pkcs12(temp_dir, temp_dir,
                                                cert_filename,
                                                key_filename,
                                                cert_name)
    CertUtils.import_cert_and_pkcs12(src_dir, cert_filename,
                                     pkcs12_filename, cert_name, ',,')

    return [cert_name, key_filename, cert_filename]
开发者ID:Bouh,项目名称:gecko-dev,代码行数:83,代码来源:generate_ev.py

示例15: generate_and_maybe_import_cert

# 需要导入模块: import CertUtils [as 别名]
# 或者: from CertUtils import generate_cert_generic [as 别名]
def generate_and_maybe_import_cert(key_type, cert_name_prefix, cert_name_suffix,
                                   base_ext_text, signer_key_filename,
                                   signer_cert_filename, key_size, generate_ev):
    """
    Generates a certificate and imports it into the NSS DB if appropriate.

    Arguments:
      key_type -- the type of key generated: potential values: 'rsa', or any of
                  the curves found by 'openssl ecparam -list_curves'
      cert_name_prefix -- prefix of the generated cert name
      cert_name_suffix -- suffix of the generated cert name
      base_ext_text -- the base text for the x509 extensions to be added to the
                       certificate (extra extensions will be added if generating
                       an EV cert)
      signer_key_filename -- the filename of the key from which the cert will
                             be signed. If an empty string is passed in the cert
                             will be self signed (think CA roots).
      signer_cert_filename -- the filename of the signer cert that will sign the
                              certificate being generated. Ignored if an empty
                              string is passed in for signer_key_filename.
                              Must be in DER format.
      key_size -- public key size for RSA certs
      generate_ev -- whether an EV cert should be generated

    Output:
      cert_name -- the resultant (nick)name of the certificate
      key_filename -- the filename of the key file (PEM format)
      cert_filename -- the filename of the certificate (DER format)
    """
    cert_name = cert_name_prefix + '_' + key_type + '_' + key_size

    # If the suffix is not the empty string, add a hyphen for visual separation
    if cert_name_suffix:
        cert_name += '-' + cert_name_suffix

    ev_ext_text = ''
    subject_string = ('/CN=XPCShell Key Size Testing %s %s-bit' %
                      (key_type, key_size))
    if generate_ev:
        cert_name = 'ev_' + cert_name
        ev_ext_text = (aia_prefix + cert_name + aia_suffix +
                       mozilla_testing_ev_policy)
        subject_string += ' (EV)'

    # Use the organization field to store the cert nickname for easier debugging
    subject_string += '/O=' + cert_name

    [key_filename, cert_filename] = CertUtils.generate_cert_generic(
        db_dir,
        srcdir,
        random.randint(100, 40000000),
        key_type,
        cert_name,
        base_ext_text + ev_ext_text,
        signer_key_filename,
        signer_cert_filename,
        subject_string,
        key_size)

    if generate_ev:
        # The dest_dir argument of generate_pkcs12() is also set to db_dir as
        # the .p12 files do not need to be kept once they have been imported.
        pkcs12_filename = CertUtils.generate_pkcs12(db_dir, db_dir,
                                                    cert_filename, key_filename,
                                                    cert_name)
        CertUtils.import_cert_and_pkcs12(srcdir, cert_filename, pkcs12_filename,
                                         cert_name, ',,')

        if not signer_key_filename:
            generated_ev_root_filenames.append(cert_filename)

    return [cert_name, key_filename, cert_filename]
开发者ID:ashishrana7,项目名称:firefox,代码行数:74,代码来源:generate.py


注:本文中的CertUtils.generate_cert_generic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。