Skip to content

Commit 53388dc

Browse files
committed
[push] Fix for upload of APN credentials from windows / no mime-aware systems
1 parent 0633478 commit 53388dc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

plugins/push/api/parts/endpoints.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -976,22 +976,22 @@ function catchy(f) {
976976
mime = data.file.indexOf(';base64,') === -1 ? null : data.file.substring(0, data.file.indexOf(';base64,')),
977977
detected;
978978

979-
if (mime === 'data:application/x-pkcs12') {
979+
if (mime === 'data:application/x-pkcs12' || (mime === 'data:application/octet-stream' && data.fileType === 'p12')) {
980980
detected = C.CRED_TYPE[N.Platform.IOS].UNIVERSAL;
981981
} else if (mime === 'data:application/x-pkcs8') {
982982
detected = C.CRED_TYPE[N.Platform.IOS].TOKEN;
983-
} else if (mime === 'data:') {
983+
} else if (mime === 'data:' || (mime === 'data:application/octet-stream' && data.fileType === 'p8')) {
984984
var error = C.check_token(data.file.substring(data.file.indexOf(',') + 1), [data.key, data.team, data.bundle].join('[CLY]'));
985985
if (error) {
986-
return resolve('Push: ' + (typeof error === 'string' ? error : error.message || error.code || JSON.stringify(error)));
986+
return reject('Push: ' + (typeof error === 'string' ? error : error.message || error.code || JSON.stringify(error)));
987987
}
988988
detected = C.CRED_TYPE[N.Platform.IOS].TOKEN;
989989
} else {
990-
return resolve('Push: certificate must be in P12 or P8 formats');
990+
return reject('Push: certificate must be in P12 or P8 formats');
991991
}
992992

993993
if (data.type && detected !== data.type) {
994-
return resolve('Push: certificate must be in P12 or P8 formats (bad type value)');
994+
return reject('Push: certificate must be in P12 or P8 formats (bad type value)');
995995
} else {
996996
data.type = detected;
997997
}

plugins/push/frontend/public/javascripts/countly.views.js

+8
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ app.addAppManagementView('push', jQuery.i18n.map['push.plugin-title'], countlyMa
100100
var data = JSON.parse(JSON.stringify(this.templateData));
101101

102102
if (data.i.file) {
103+
if (data.i.file.indexOf('.p8') === data.i.file.length - 3) {
104+
data.i.fileType = 'p8';
105+
} else if (data.i.file.indexOf('.p12') === data.i.file.length - 4) {
106+
data.i.fileType = 'p12';
107+
} else {
108+
return $.Deferred().reject('File type not supported');
109+
}
110+
103111
var d = new $.Deferred(),
104112
reader = new window.FileReader();
105113

0 commit comments

Comments
 (0)