我一直在努力使用acquire\u token \u with \u client \u certificate函数检索令牌。无论我使用何种PEM编码密钥/证书,我都会收到以下错误:
AdalError: Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS70002: Error validating credentials. AADSTS50032: RSA key size 1024 is less than the minimum required 2048 bits.\r\nTrace ID: 32bf21de-e77a-4419-ab2b-cdc3a9343200\r\nCorrelation ID: 291050ae-0e86-4d09-bd62-7cfc53750db9\r\nTimestamp: 2018-04-16 13:51:50Z","error_codes":[70002,50032],"timestamp":"2018-04-16 13:51:50Z","trace_id":"32bf21de-e77a-4419-ab2b-cdc3a9343200","correlation_id":"291050ae-0e86-4d09-bd62-7cfc53750db9"}
我的代码如下:
def get_private_key(filename):
with open(filename, 'r') as pem_file:
private_pem = pem_file.read()
return private_pem
context = adal.AuthenticationContext(authority_url, api_version=None)
key = get_private_key('../keys/fullkey.pem')
token = context.acquire_token_with_client_certificate(
resource_id,
client_id,
key,
thumbprint_new)
print token
无论我指向哪个.pem文件(为了调试,我生成了多个文件),我都会继续收到相同的错误。你知道吗
任何帮助都将不胜感激!你知道吗
谢谢你, 迈克
收到此错误是因为您作为输入提供的RSA密钥大小小于2048。您可以通过将密钥大小增加到2048位或更多来解决此问题。你知道吗
以下是生成私钥文件和证书的步骤,可用于adalpython中的身份验证。你知道吗
openssl genrsa -out server.pem 2048
openssl req -new -key server.pem -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.pem -out server.crt
您必须将此证书(
server.crt
)上载到应用程序设置中的Azure门户上。保存此证书后,门户将为您提供获取令牌调用中所需的此证书的指纹。该键将是您在第一步中生成的server.pem
键。你知道吗相关问题 更多 >
编程相关推荐