예제 #1
0
    def test_ext(self):
        if 0:  # XXX
            # With this leaks 8 bytes:
            name = "proxyCertInfo"
            value = "critical,language:Inherit all"
        else:
            # With this there are no leaks:
            name = "nsComment"
            value = "Hello"

        ctx = m2.x509v3_set_nconf()
        x509_ext_ptr = m2.x509v3_ext_conf(None, ctx, name, value)
        X509.X509_Extension(x509_ext_ptr, 1)
예제 #2
0
def _workaround_new_extension(name, value, critical=False, issuer=None, _pyfree=1):
    # m2crypto removes x509v3_lhash with 0.25.1
    try:
        ctx = m2.x509v3_set_nconf()
        if ctx is None:
            raise MemoryError()
        _init_m2_ctx(ctx, issuer)
        x509_ext_ptr = m2.x509v3_ext_conf(None, ctx, name, value)
    except AttributeError:
        lhash = m2.x509v3_lhash()
        ctx = m2.x509v3_set_conf_lhash(lhash)
        _init_m2_ctx(ctx, issuer)
        x509_ext_ptr = m2.x509v3_ext_conf(lhash, ctx, name, value)

    if x509_ext_ptr is None:
        raise Exception('Could not create the X509v3 extension')

    x509_ext = X509.X509_Extension(x509_ext_ptr, _pyfree)
    x509_ext.set_critical(critical)
    return x509_ext