小编use*_*083的帖子

如何编码JWT进行APN标记化(.NET,C#)

我正在尝试使用标记化将推送通知发送到APN.我试图使用像jose-jwt和Microsot Jwt类这样的库来创建JWT令牌,但我无法绕过它.

我坚持创建JWT并使用私钥对其进行签名.

为了与证书通信,我使用了PushSharp,它工作得很好.任何人都可以用一个类似的例子帮助我,但是有令牌吗?

编辑:关注Apple的文档:https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

示例代码:我最接近的东西看起来像这样,但我不知道如何正确创建CngKey

var payload = new Dictionary<string, object>()
            {
                { "iss", issuer },
                { "iat", DateTime.UtcNow }
            };

var headers = new Dictionary<string, object>()
            {
                 { "kid", keyIdentifier}
            };

CngKey key = CngKey.Create(CngAlgorithm.ECDsaP256); //how to create this CngKey

string token = Jose.JWT.Encode(payload, key, JwsAlgorithm.ES256, headers);
Run Code Online (Sandbox Code Playgroud)

.net c# token apple-push-notifications jwt

4
推荐指数
1
解决办法
1776
查看次数

标签 统计

.net ×1

apple-push-notifications ×1

c# ×1

jwt ×1

token ×1