我对Azure Active Directory使用了令牌认证(而不是cookie)。.NET核心和Azure Active Directory集成
基于这篇文章:https://www.itunity.com/article/angular-2-openid-connect-azure-active-directory-3093
我能得到它的工作在客户端。
public validateSignature(token): Observable<boolean> {
/* Retrieve from federated metadata endpoint.
In this sample, the document was downloaded locally */
return this.httpService.get("metadata/metadata.xml")
.map((res: Response) => {
let dom = (new DOMParser()).parseFromString(res.text(), "text/xml");
let json = xml2json(dom, "");
let cert = "-----BEGIN CERTIFICATE-----" +
JSON.parse(json).EntityDescriptor[0]["ds:Signature"]
["KeyInfo"]["X509Data"]["X509Certificate"] +
"-----END CERTIFICATE-----";
let key = KEYUTIL.getKey(cert);
return KJUR.jws.JWS.verifyJWT(token, key, { alg: ['RS256'] });
})
}
我试图重新实现在.NET核心1.0.3上述方法。
基于这篇文章:how to sign and verify signature with net and a certificate
下面的行不会编译.NET的核心:
RSACryptoServiceProvider csp = (RSACryptoServiceProvider)cert.PublicKey.Key;
我不知道什么是验证基于证书的令牌正确的方法.NET核心。
它按预期工作。谢谢! –
@DerekLiang如果问题有帮助,请将其标记为答案,以便具有相同问题的社区可以轻松识别有用的帖子:) –
我将ValidateIssuerSigningKey设置为true,但没有签名密钥。当我将SymmetricSecurityKey值添加到IssuerSigningKey属性时,不管赋予什么值,都不起作用。我假设它只会验证我拥有的密钥。 – RyanOC