我一直在尝试使用新的iOS Game Center GKPlayer方法,generateIdentityVerificationSignatureWithCompletionHandler,这样我们就可以安全地依赖Game Center凭据进行身份验证.我们使用Node.js作为后端服务器,我一直在尝试验证签名,但无济于事.
以下是我所拥有的服务器端代码 - 如果有人可以查看缺少的内容,那将不胜感激.问题在这里有所回答:如何在我的'第三方服务器'上验证GKLocalPlayer?,但Node.js没有专门解决.请注意,下面的代码不能确保具有签名权限的证书的有效性(尚未).
//Client sends the payload below
//json.playerId - UTF-8 string
//json.bundleId - UTF-8 string
//json.timestamp - Hex string
//json.salt - base64 encoded
//json.publicKeyURL - UTF-8 string
//json.signature - base64 encoded
var json = JSON.parse(req.body);
console.log(JSON.stringify(json));
//get the certificate
getCertificate(json.publicKeyURL, function(cert){
//read file from fs for now, since getCertificate returns cert in DER format
fs = require('fs');
fs.readFile('/gc-sb.pem', 'utf8', function (err,data) {
if (err) {
console.log(err);
} else {
console.log(data); …Run Code Online (Sandbox Code Playgroud)