In my tizen werable web application (target: tizen 2.3.2) I need to get public key of author certificate (used for sign app) for check token of paired smartphone app in SAP [Samsung Accessory Protocol] authentication implementation.
Werable app and smartphone app (android) are signed with same keystore.
Is it possible via packageManager API or similar?
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);
}
});
Found. First of all in config.xml of web application add CERTIFICATE privilege:
<tizen:privilege name="http://tizen.org/privilege/appmanager.certificate"/>
Then simply call getAppCert method of tizen.application:
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 privilege need signing AuthorCertificate of PARTNER level to be used, for PUBLIC AuthorCertificate it return this exception during app installation:
- [MISMATCHED_PRIVILEGE_LEVEL]Signature Level is too low to use http://tizen.org/privilege/appmanager.certificate - Signature Level = public, Privilege Level = partner
More info about Tizen privileges are available here: https://www.tizen.org/tv/privilege
Info about privileges security system: https://developer.tizen.org/dev-guide/2.4/org.tizen.gettingstarted/html/web/details/sec_privileges_w.htm
API reference to get Public Key of signing certificates at runtime: https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/2.3.2/org.tizen.web.apireference/html/device_api/wearable/tizen/application.html#ApplicationManager::getAppCerts