在我的 tizen werable web application (目标: tizen 2.3.2 )中,我需要获取作者证书的公钥(用于签名应用)以获取支票令牌配对智能手机应用 SAP [ Samsung Accessory Protocol ]身份验证实施。
Werable app和智能手机应用程序(android)使用相同的密钥库签名。
是否可以通过packageManager API或类似方法?
var myAppSigCert = "";//I NEED THIS ONE
SAAgent.authenticatePeerAgent(peerAgent,
function(peerAgent, authToken){
if (authToken.key === myAppSigCert ) {
alert("Service connection request accepted: " + peerAgent.appName);
SAAgent.acceptServiceConnectionRequest(peerAgent);
}else{
alert("Service connection request REJECT: " + peerAgent.appName);
SAAgent.rejectServiceConnectionRequest(peerAgent);
}
});
答案 0 :(得分:1)
实测值。首先,在Web应用程序的 config.xml 中添加 CERTIFICATE 权限:
<tizen:privilege name="http://tizen.org/privilege/appmanager.certificate"/>
然后只需调用 tizen.application 的 getAppCert 方法:
var appCerts = tizen.application.getAppCerts(null);
for (var i = 0; i < appCerts.length; i++) {
console.log("#" + i + " type:" + appCerts[i].type);
console.log("#" + i + " value:" + appCerts[i].value);
}
appmanager.certificate 权限需要为 PUBLIC 签署 PARTNER 级别的 AuthorCertificate AuthorCertificate 它在应用安装期间返回此异常:
- [MISMATCHED_PRIVILEGE_LEVEL]Signature Level is too low to use http://tizen.org/privilege/appmanager.certificate - Signature Level = public, Privilege Level = partner
有关Tizen权限的更多信息,请点击此处 https://www.tizen.org/tv/privilege
有关特权安全系统的信息: https://developer.tizen.org/dev-guide/2.4/org.tizen.gettingstarted/html/web/details/sec_privileges_w.htm
答案 1 :(得分:-1)
作者证书有助于维护Tizen Gear App和Android之间的安全对等身份验证 移动应用。 Certificate Extension SDK支持基于Android密钥库文件创建Tizen作者证书。
Creating Gear Author Certificate Using Android Keystore&gt;&gt;教程附录D
创建证书后,您可以从计算机上找到作者证书的公钥
/tizen-sdk-data/keystore/author-name/author
在您的代码中使用它,如
// from sample app
var authTokenKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhO5x67wRt3Ni5A4n+HBbAczE6p8lAEgnywXInIUMKuCDSaEpM3EwYE6GUGACDbAoCx7EBTS54XbLWrnz10XZAKZyMoQidI+JWiSwlNYOxGlfHJgxVEExr2ZmlKVYedQxlGZNsLjGziYW0Y6UIXmDOeDA1b4g7Grbx0vS1BXC3Mv8s/8zlAl3NPj6BU1mh2hWKJL9+eDaM3bmYK1JJ9jbLlIzCsl0fZ4kR1xlSToZDBk53LxO0n1ekUpsEmMbFcmj1KKGQQn6A+ej0s5iOlXz6dgDfg4PxoTnlutwLOilz4zJLySZA6o3jG2kYls6ZBEjaz9ZeHxQlEV9PKh/Vgq8wwIDAQAB"
/* Authentication of requesting peer agent */
if (typeof(SAAgent.authenticatePeerAgent) === 'function') {
SAAgent.authenticatePeerAgent(
peerAgent,
function (peerAgent, authToken) {
/* Authentication token of peer agent arrives */
if (authToken.key === authTokenKey) {
SAAgent.acceptServiceConnectionRequest(peerAgent);
createHTML("Service connection request accepted via authenticatePeerAgent");
} else {
SAAgent.rejectServiceConnectionRequest(peerAgent);
createHTML("Service connection request rejected via authenticatePeerAgent");
}
},
function (e) {
/* Error handling */
SAAgent.rejectServiceConnectionRequest(peerAgent);
createHTML("Service connection request rejected due to error:<br />" +
"Error name : " + e.name + "<br />" +
"Error message : " + e.message);
}
);
}
找到SAP的sample app。