Loading a pem file as Buffer through the Assets api fails

I’m writing a custom authorization system similar to OAuth as a Meteor package.

As part of the authorization I authenticate a SAML Signature using a pem certificate.

  • The package loads the pem file as a static asset on the server.

  • The server loads the file by creating a new Buffer with Assets.getText or Assets.getBinary, but fails when authenticating.

    //FAILS:
    const cert = new Buffer( Assets.getBinary(‘private/test.pem’) );
    const cert = new Buffer( Assets.getText(‘private/test.pem’).toString(‘binary’) );

  • When I test the package with vanilla node, while using fs to load the pem file it works:

    //WORKS:
    const cert = new Buffer( fs.readFileSync(‘private/test.pem’) );

It seems like Meteor’s Assets api makes a change to the file that makes the certificate invalid when authenticating the signature.

Any ideas on what might cause this behaviour?

maybe don’t include private/

Static server assets are included by placing them in the application’s private subdirectory. For example, if an application’s private subdirectory includes a directory called nested with a file called data.txt inside it, then server code can read data.txt by running:

1
var data = Assets.getText(‘nested/data.txt’);