- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Apple 是否有任何文档涵盖用于生成由 - [GKLocalPlayer generateIdentityVerificationSignatureWithCompletionHandler:]
返回的文件的格式或算法?
我见过 few questions关于认证用户的基本流程,这似乎表明该文件是一个 .cer 文件(application/pkix-cert),并且它使用 DER 文件格式,但我找不到 Apple 的任何官方信息。
我正在寻找用 Java 验证证书,如果有人有任何示例,也将不胜感激。
最佳答案
[localPlayer generateIdentityVerificationSignatureWithCompletionHandler:^(NSURL *publicKeyUrl, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) {
if(error != nil){
//login failed.
}else{
NSLog(@"signature : %@", [signature base64Encoding]);
NSLog(@"salt : %@", [salt base64Encoding]);
NSLog(@"PUBLIC_KEY_URL : %@", publicKeyUrl);
NSLog(@"signature : %@", [signature base64EncodedStringWithOptions:0]);
NSLog(@"salt : %@", [salt base64EncodedStringWithOptions:0]);
NSLog(@"timestamp : %lld", timestamp);
NSLog(@"Gamecenter login success.");
NSMutableData *payload = [[NSMutableData alloc] init];
[payload appendData:[[GKLocalPlayer localPlayer].playerID dataUsingEncoding:NSUTF8StringEncoding]];
[payload appendData:[[[NSBundle mainBundle] bundleIdentifier] dataUsingEncoding:NSUTF8StringEncoding]];
uint64_t timestampBE = CFSwapInt64HostToBig(timestamp);
[payload appendBytes:×tampBE length:sizeof(timestampBE)];
[payload appendData:salt];
NSString *ext_id = localPlayer.playerID;
NSString *encodedSignedData = [payload base64EncodedStringWithOptions:0];
NSLog(@"SIGNEDDATA : %@", encodedSignedData);
NSString *encodedSignature = [signature base64Encoding];
NSString *publicKeyUrlStr = [publicKeyUrl absoluteString];
}
}];
public static String makeEncodedSignedDataForAppleVerify(String player_id, String bundle_id, String timestamp, String salt){
return new String(Base64.encodeBase64(concat(player_id.getBytes(),
bundle_id.getBytes(),
ByteBuffer.allocate(8).putLong(Long.parseLong(timestamp)).array(),
Base64.decodeBase64(salt))));
}
public static boolean gamecenterUserVerify(String publicKeyUrl, String signedData, String signature){
try{
URL url = new URL(publicKeyUrl);
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) urlConn;
httpConn.setAllowUserInteraction(false);
httpConn.connect();
InputStream in = httpConn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(in);
ByteArrayBuffer baf = new ByteArrayBuffer(99999);
int read = 0;
int bufSize = 512;
byte[] buffer = new byte[bufSize];
while(true){
read = bis.read(buffer);
if(read==-1){
break;
}
baf.append(buffer, 0, read);
}
byte[] bytes =baf.toByteArray();
bis.close();
in.close();
httpConn.disconnect();
CertificateFactory cf = CertificateFactory.getInstance("X509");
X509Certificate c = (X509Certificate)
cf.generateCertificate(new ByteArrayInputStream(bytes) );
PublicKey key22 = c.getPublicKey();
byte[] result = Base64.decodeBase64(signedData);//;
byte[] decodedSignature = Base64.decodeBase64(signature);
Signature sig;
try {
sig = Signature.getInstance("SHA256withRSA");
sig.initVerify(key22);
sig.update(result);
if (!sig.verify(decodedSignature)) {
return false;
}else{
return true;
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (SignatureException e) {
e.printStackTrace();
}
}catch(Exception e){
e.printStackTrace();
}
return false;
}
static byte[] concat(byte[]...arrays)
{
// Determine the length of the result array
int totalLength = 0;
for (int i = 0; i < arrays.length; i++)
{
totalLength += arrays[i].length;
}
// create the result array
byte[] result = new byte[totalLength];
// copy the source arrays into the result array
int currentIndex = 0;
for (int i = 0; i < arrays.length; i++)
{
System.arraycopy(arrays[i], 0, result, currentIndex, arrays[i].length);
currentIndex += arrays[i].length;
}
return result;
}
关于java - GKLocalPlayer generateIdentityVerificationSignatureWithCompletionHandler 返回的 "public key"文档 :?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26900116/
我正在构建一个游戏,我将 Apple 的服务与我自己的服务器结合使用,我想获取本地用户的电子邮件信息和昵称 最佳答案 昵称(Alias)可以通过使用得到 GKLocalPlayer *localPla
我在我的应用程序中使用 Game Center,但我在 GKLocalPlayer.authenticated 属性方面遇到了一些问题。无论身份验证过程是否成功,localPlayer.authent
我想用 GKLocalPlayer 和 saveGameData 方法保存游戏数据。 [localPlayer saveGameData:playerData withName:@"SolarFlar
我有以下用于验证 GKLocalPlayer 的代码: var cert = await GetCertificate(gameCenter.PublicKeyURL); if (cert.Verif
在Apple's Doc, generateIdentityVerificationSignatureWithCompletionHandler ,你要将 4 个参数拼接成一个数据缓冲区,其中一个是“
我正在使用游戏中心制作 Sprite Kit 多人游戏。 我正在使用以下代码获取本地播放器。 GKLocalPlayer.localPlayer() 我用它来获取像玩家 ID 和别名这样的东西: GK
我正在尝试使用 Game Center 验证 GKLocalPlayer。但是,Apple 提供的代码 - (void) authenticateLocalPlayer { [[GKLocal
我的应用会记录它是否成功通过 Game Center 的身份验证。当它开始新游戏或当用户查看得分列表时,如果本地玩家未成功通过身份验证,并且如果该应用当时未在尝试对用户进行身份验证,它会再次尝试. (
Apple 是否有任何文档涵盖用于生成由 - [GKLocalPlayer generateIdentityVerificationSignatureWithCompletionHandler:] 返
iOS7 引入了新的 GKLocalPlayer 方法 generateIdentityVerificationSignatureWithCompletionHandler()。 有谁知道如何永久使用
在沙盒模式下测试时,[[GKLocalPlayer localPlayer] displayName] 总是返回 @"Me"。这是否也发生在 Game Center 的生产服务器上? 部分解决方案是使
使用Apple的Game Center认证验证步骤outlined here ,下面的验证逻辑是用Java实现的。然而,这总是失败。 import java.net.URL; import java.
This和 this不要编译。 我的 SpriteKitSceneViewController 中的代码, var localPlayer = GKLocalPlayer.localPlayer()
请原谅我的笨拙,我是 Stackoverflow、C# 和 Objective C 的新手。 简而言之,我正在尝试做这个问题的答案,但在 PHP 中: How to authenticate the
我正致力于在我的游戏中集成回合制比赛,几天前我开始从 GameKit API 收到奇怪的错误,提示本地玩家未通过身份验证,尽管他已经通过身份验证。 当我启动应用程序时,authenticateHand
我是一名优秀的程序员,十分优秀!