【发布时间】:2021-06-20 01:54:21
【问题描述】:
从这里下载源代码:https://developer.samsung.com/galaxy-watch-develop/samples/companion/hello-native.html
这里也试过:https://developer.samsung.com/galaxy-watch-develop/samples/companion/security-native.html
但无法在 Tizen 和 Android 之间获得“安全”套接字。
下面是一些来自 Android 的有用日志(这部分似乎失败了):
2021-03-23 18:21:37.903 10288-10365/com.samsung.android.sdk.accessory.example.provider D/AccessoryProvider(P): onAuthenticationResponse
2021-03-23 18:21:37.909 10288-10365/com.samsung.android.sdk.accessory.example.provider D/AccessoryProvider(P): onAuthenticationResponse: matched=false, authToken.getKey().length=294, myAppKey.length=162
2021-03-23 18:21:37.910 10288-10365/com.samsung.android.sdk.accessory.example.provider I/[SA_SDK]SAAgentV2: onAuthenticationResponse() -> AUTHENTICATION_SUCCESS
中间线是我的,问题是 SAP 给我的authToken 与myAppKey 不匹配。即使通过比较它们的大小也无法匹配。
所以,如果您对 authToken.getKey() 是什么以及它是什么类型的密钥(长度为 294 字节)有任何想法,请告诉我。
myAppKey 是这样构造的:
Signature[] sigs = pkgInfo.signatures;
Log.d(TAG, "getApplicationCertificate, sigs[0].toByteArray().length=" + sigs[0].toByteArray().length); //481
CertificateFactory cf = CertificateFactory.getInstance("X.509");
ByteArrayInputStream stream = new ByteArrayInputStream(sigs[0].toByteArray());
X509Certificate x509cert = X509Certificate.getInstance(stream);
myAppKey = x509cert.getPublicKey().getEncoded();
Log.d(TAG, "getApplicationCertificate, x509cert.getPublicKey().getEncoded().length=" + x509cert.getPublicKey().getEncoded().length); //162
【问题讨论】: