2014-05-21 15 views
5

Tôi đang sử dụng APN để gửi thông báo đẩy từ ứng dụng node.js lên Apple.Ứng dụng bị kẹt với 'Nhập cụm từ mật khẩu PEM' sau khi gửi thông báo đẩy

Mã của tôi:

// send to development**** 
    var dev_cert_path = path.join(__dirname, '..', 'cert.pem'); 
    var dev_key_path = path.join(__dirname, '..', 'key.pem'); 
    var devOptions = { "gateway": "gateway.sandbox.push.apple.com" , "cert": dev_cert_path, "key": dev_key_path, "passphrase":'XXXXX'}; 


    var devApnConnection = new apn.Connection(devOptions) 
    , devMyDevice = new apn.Device(token) 
    , devNote = new apn.Notification(); 

    devNote.expiry = Math.floor(Date.now()/1000) + 3600; // Expires 1 hour from now. 
    devNote.badge = 3; 
    devNote.sound = "xxx.aiff"; 
    devNote.alert = message; 
    devNote.payload = {'messageFrom': ''}; 
    devApnConnection.pushNotification(devNote, devMyDevice); 
    var options = { 
    "batchFeedback": true, 
    "interval": 1 
    }; 

    var devFeedback = new apn.Feedback(options); 
     devFeedback.on("feedback", function(devices) { 
      devices.forEach(function(item) { 
       logger.debug("device error : " + item.device); 
       // Do something with item.device and item.time; 
      }); 
    }); 

    devApnConnection.on('transmitted', function(res){ 
     logger.debug("sent this message:"+JSON.stringify(devNote)+ " to this device: " + devMyDevice); 
    }); 

    devApnConnection.on('error', function(res){ 
     logger.error("sending message failed to this device: " + devMyDevice + " data: " + JSON.stringify(res)); 
    }); 


} 
catch(e) 
    {logger.error("Push notification error: ",e.message);} 

Vấn đề của tôi:

Khi gửi một yêu cầu đến Node.js, nó gửi một thông báo đẩy, nhưng tôi nhận được nhiều Enter PEM pass phrase: tại nhà ga :

/projects/my_app$ node app.js 

POST /requests 200 14ms 
Enter PEM pass phrase: 
Enter PEM pass phrase: 
Enter PEM pass phrase: 
Enter PEM pass phrase: 
Enter PEM pass phrase: 
Enter PEM pass phrase: 

Vì vậy, ứng dụng của tôi bị kẹt cho đến khi không khởi động lại nút ... Bất kỳ ý tưởng nào?

Edit:

tôi đã cố gắng để loại bỏ mật khẩu từ file:

openssl rsa -in key.pem -out nopassword.pem 

Nhưng tôi vẫn nhận này trong ứng dụng giao diện điều khiển - nhưng khi nhấn enter, nó dừng lại chụp thông điệp này , cho đến khi yêu cầu tiếp theo (trước khi xóa thẻ, nó hiển thị nhiều tin nhắn cho đến khi khởi động lại ứng dụng, cũng như khi nhấp vào nhập hoặc cụm từ mật khẩu ...

Trả lời

6

Tôi đã tìm thấy sự cố ...

Tôi phải thêm cert, key và cụm mật khẩu vào tùy chọn phản hồi.

var options = { 
    "batchFeedback": true, 
    "interval": 300 
}; 

var devFeedback = new apn.Feedback(options); 
     devFeedback.on("feedback", function(devices) { 
      devices.forEach(function(item) { 
       logger.debug("device error : " + item.device); 
       // Do something with item.device and item.time; 
      }); 
}); 

Các tùy chọn nên là:

+1

Không hoạt động cho tôi –

+0

Vẫn nhận được 'Nhập cụm từ thông qua PEM:'? Chia sẻ mã của bạn. – user2503775

0

Dường như bạn đặt một thách thức mật khẩu trong khi tạo tin chính & CSR. Miễn là bạn biết mật khẩu sử dụng openssl để tách nó ra thành một tập tin mới mà bạn sẽ cần phải sử dụng.

openssl rsa -in private.key -out private-wo.key -passin pass:<PASSWORD> 
Các vấn đề liên quan