我试图从一个.core应用程序中获得application连接API。
我现在有
var key = <contents of p8 file>;
var credentials = new SigningCredentials(
new SymmetricSecurityKey(Encoding.ASCII.GetBytes(key)),
SecurityAlgorithms.EcdsaSha256
);
var header = new JwtHeader(credentials);
header.Add("kid", KeyID);
var payload = new JwtPayload
{
{ "aud ", "appstoreconnect-v1"},
{ "exp", exp},
{"iss", issuerID }
};
var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();
var tokenString = handler.WriteToken(secToken);
我的问题是
无法创建SignatureProvider。\nAlgorithm:'System.String',不支持'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey'\n :SecurityKey。支持的算法列表如下:https://aka.ms/IdentityModel/supported-algorithms"
发布于 2022-06-16 13:15:08
你从苹果下载的p8文件没有加密。使用openssl命令,您可以将其转换为未加密和加密的.pem文件。您还可以提取公钥。
就个人而言,我创建了包含私钥的pem文件,并使用这个文件创建了客户端秘密,然后,也就是我在https://jwt.io中验证的jwt。
发布于 2022-10-19 15:54:58
Ecdsa是一种非对称算法,您在签名凭据中使用对称密钥。您应该在Ecdsa中使用非对称密钥,或者在SymmetricSecurityKey中使用对称算法。
https://stackoverflow.com/questions/69517726
复制相似问题