Use client.pfx to authenticate against server


#1

Hi,

I want to use a client.pfx certificate to authenticate against a server. Can we already do this? in node that code reads the .pfx in the current directory…

function getCertificates(cert, certKey) {
var certificate = {};
var _cert = null;
var _certKey = null;

var files = ["client.pem", "client.pfx", "C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\client.pem"];
files.unshift(cert);
files = _.uniq(files);

for (var obj in files) {
    _cert = getFileRealPath(files[obj]);
    if (_cert != null)
        break;
}

if (_cert != null) {
    try {
        if (_cert.toLowerCase().indexOf(".pem") > 0) {
            // .pem
            var files = ["client_key.pem", "C:\\ProgramData\\Qlik\\Sense\\Repository\\Exported Certificates\\.Local Certificates\\client_key.pem"];
            files.unshift(certKey);
            files = _.uniq(files);

            for (var obj in files) {
                _certKey = getFileRealPath(files[obj]);

                if (certKey != null) {
                    certificate.cert = fs.readFileSync(_cert);
                    certificate.key = fs.readFileSync(_certKey);
                    break;
                }
            }
        } else {
            // .pfx
            certificate.pfx = fs.readFileSync(_cert);
        }
    } catch (e) {
        // nothing to see here...
    }
}
return certificate;

}


#2

This is still possible. you only have to make sure you specify the path to the pfx file, otherwise it does not work