當前位置: 首頁>>代碼示例>>Python>>正文


Python CertUtils.generate_int_and_ee方法代碼示例

本文整理匯總了Python中CertUtils.generate_int_and_ee方法的典型用法代碼示例。如果您正苦於以下問題:Python CertUtils.generate_int_and_ee方法的具體用法?Python CertUtils.generate_int_and_ee怎麽用?Python CertUtils.generate_int_and_ee使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CertUtils的用法示例。


在下文中一共展示了CertUtils.generate_int_and_ee方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_certs

# 需要導入模塊: import CertUtils [as 別名]
# 或者: from CertUtils import generate_int_and_ee [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

示例2: generate_certs

# 需要導入模塊: import CertUtils [as 別名]
# 或者: from CertUtils import generate_int_and_ee [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

示例3: generate_certs

# 需要導入模塊: import CertUtils [as 別名]
# 或者: from CertUtils import generate_int_and_ee [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

示例4: generate_certs

# 需要導入模塊: import CertUtils [as 別名]
# 或者: from CertUtils import generate_int_and_ee [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)

    # 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",
        EE_basic_constraints
        + EE_full_ku
        + Server_eku
        + authority_key_ident
        + 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 = (
        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
        + 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_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
#.........這裏部分代碼省略.........
開發者ID:randombit,項目名稱:hacrypto,代碼行數:103,代碼來源:generate.py


注:本文中的CertUtils.generate_int_and_ee方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。