Example #1
0
def import_rsa_key(key, passphrase=None):
    """
    Extract an RSA key from a PEM-encoded certificate
    :param key: RSA key encoded in standard form
    :param passphrase: Password to open the certificate (Optional)
    :return: RSA key instance
    """
    return importKey(key, passphrase=passphrase)
Example #2
0
def import_rsa_key(key, passphrase=None):
    """
    Extract an RSA key from a PEM-encoded certificate
    :param key: RSA key encoded in standard form
    :param passphrase: Password to open the certificate (Optional)
    :return: RSA key instance
    """
    return importKey(key, passphrase=passphrase)
Example #3
0
def import_rsa_key(key):
    """
    Extract an RSA key from a PEM-encoded certificate

    :param key: RSA key encoded in standard form
    :return: RSA key instance
    """
    return importKey(key)
Example #4
0
 def get_client_alg_keys(cls, client):
     """
     Takes a client and returns the set of keys associated with it.
     Returns a list of keys.
     """
     if client.jwt_alg == 'RS256':
         keys = []
         for rsa_key in get_oidc_rsa_key_model().objects.all():
             keys.append(RSAKey(key=importKey(rsa_key.key),
                                kid=rsa_key.kid))
         if not keys:
             raise Exception('You must add at least one RSA Key.')
     elif client.jwt_alg == 'HS256':
         keys = [SYMKey(key=client.client_secret, alg=client.jwt_alg)]
     else:
         raise Exception('Unsupported key algorithm.')
     return keys
def get_client_alg_keys(client):
    """
    Takes a client and returns the set of keys associated with it.
    Returns a list of keys.
    """
    if client.jwt_alg == 'RS256':
        keys = []
        for rsakey in RSAKey.objects.all():
            keys.append(jwk_RSAKey(key=importKey(rsakey.key), kid=rsakey.kid))
        if not keys:
            raise Exception('You must add at least one RSA Key.')
    elif client.jwt_alg == 'HS256':
        keys = [SYMKey(key=client.client_secret, alg=client.jwt_alg)]
    else:
        raise Exception('Unsupported key algorithm.')

    return keys