[Node.JS][Mobile Apps] Authenticating https request with pfx certificate RRS feed

  • Question

  • In a Mobile Services API, I'm trying to authenticate a request using a .pfx file, but the certificate is not being sent in the request. I suspect that it's because of the Node version, which is 0.8.28. The same code running in my local machine with Node 4.4.2, authenticates without a problem.

    This is the code I'm trying to run:

    var options = {
        pfx: pfxCertificate,
        passphrase: passphrase,
        rejectUnauthorized: true,
        hostname: host,
        port: port,
        path: path
    var callback = function(response) {
        console.log("Response: ", response);
        var str = '';
        response.on('data', function (chunk) {
            str += chunk;
        response.on('end', function () {
    https.request(options, callback).end();

    Monday, May 2, 2016 10:09 PM


  • If you are upgrading your server code, you need to update to the latest version of the Mobile Apps Server sdk, 
    Wednesday, May 4, 2016 10:38 PM

All replies

  • I'd recommend switching over to Azure App Service Mobile Apps - it is the latest SDK version and has a lot more flexibility on node versions - just about everything up to the latest version is allowed.

    We don't support certificate authentication explicitly, but given you have control over everything, this can be easily added.

    Monday, May 2, 2016 11:57 PM
  • What do you set the `pfxCertificate` in your code? the path of certificate file or certificate string? And the code you provided is the code in Custom API scripts?
    Tuesday, May 3, 2016 3:09 AM
  • After some research, I've found out that node 0.8.28 doesn't support TLS 1.2 and that's why the authentication is failling.

    We tried to make the upgrade to Mobile Apps some time ago, but it was still unstable. Is it stable enough for production? If something goes wrong after the upgrade, is there a way back?

    • Edited by Kenyon Tu Tuesday, May 3, 2016 12:28 PM
    Tuesday, May 3, 2016 12:09 PM
  • The pfxCertificate is a buffer from a .pfx file downloaded from a remote server. And yes, this code is running in a Custom API script

    Tuesday, May 3, 2016 12:14 PM
  • I made a clone from the Mobile Services App and did the upgrade, everything worked out of the box, then I did the node version upgrade by uploading the Node executable file (as setting the version in the package.json file or the WEBSITE_NODE_DEFAULT_VERSION property did not work), I used two versions, 4.4.2 which is the one running on my local machine and 0.11.6 which is the first version to support TLS 1.2, but both ended in conflict with the sqlserver module. This is the error log:

    Unaught exception: Error: The module has not been pre-compiled for node.js version v0.11.6.

    I did some research and found out that the sqlserver module contains a pre-built node in a version that it supports, but by manually setting the node executable seems to override it. Is there something that I can do to prevent this from happening?

    • Edited by Kenyon Tu Tuesday, May 3, 2016 8:01 PM typo
    Tuesday, May 3, 2016 7:55 PM
  • According the answer of this thread, it seems we cannot upgrade node.js veriosn of Mobile Services.

    If it is the node.js version limitation which causes this issue, you can refer to migrate your mobile service to mobile app.

    Wednesday, May 4, 2016 2:44 AM
  • If you are upgrading your server code, you need to update to the latest version of the Mobile Apps Server sdk, 
    Wednesday, May 4, 2016 10:38 PM