def main(x509_file, out="keys.jwk"):
    pb = PBase()
    ks = KeyStore(pb.http_request)

    key = x509_rsa_loads(open(x509_file).read())
    ks.add_key(key, "rsa", "sig")

    f = open(out, "w")
    txt = ks.dumps("sig")
    f.write(txt)
    f.close()
示例#2
0
def main(x509_file, out="keys.jwk"):
    pb = PBase()
    ks = KeyStore(pb.http_request)

    key = x509_rsa_loads(open(x509_file).read())
    ks.add_key(key, "rsa", "sig")

    f = open(out, "w")
    txt = ks.dumps("sig")
    f.write(txt)
    f.close()
示例#3
0
def test_init_2():
    #key, type, usage, owner
    jwt_keys = [["foobar","hmac", "sig", "."]]

    keystore = KeyStore(None, jwt_keys)

    skeys = keystore.get_sign_key()

    assert skeys == {'hmac': ['foobar']}

    skeys = keystore.get_sign_key("hmac")

    assert skeys == ['foobar']
示例#4
0
def test_key_export():
    keystore = KeyStore(None)
    part,res = keystore.key_export("http://www.example.com/as", "static",
                                   "keys", sig={"format":"jwk", "alg":"rsa"})

    print part
    assert part.scheme == "http"
    assert part.netloc == "www.example.com"
    assert part.path == "/as"
    print res
    assert res.keys() == ["jwk_url"]
    url = res["jwk_url"]
    assert url == 'http://www.example.com/as/static/jwk.json'

    assert keystore.get_sign_key("rsa")
示例#5
0
def test_3():
    jwt_keys = [["foobar","hmac", "sig", "."]]
    keystore = KeyStore(None, jwt_keys)

    keystore.set_verify_key("xyz", owner="http://example.com/")

    skeys = keystore.get_sign_key("hmac")

    assert skeys == ['foobar']

    skeys = keystore.get_verify_key("hmac", "http://example.com/")

    assert skeys == ['xyz']

    skeys = keystore.get_sign_key(owner="http://example.com/")

    assert skeys == {}
示例#6
0
def run_key_server(server_url_pattern, host):
    ks = KeyStore(None)
    part, res = ks.key_export(server_url_pattern % host, **KEY_EXPORT_ARGS)
    return start_key_server(part)