Home > Enterprise >  PBIVIZ not recognizing certificate
PBIVIZ not recognizing certificate

Time:10-28

I've been updating my development environment with the latest pbiviz stuff I did a:

npm i -g powerbi-visuals-tools

and:

pbiviz --install-cert

in Windows terminal/powershell

Then I opened a project in Visual Code and using terminal did a:

pbiviz package info Building visual... info Installing API: ~3.8.0...

Certificate is invalid! warn Local valid certificate not found. info Checking global instance of pbiviz certificate...

warn Global instance of valid pbiviz certificate not found. info Generating a new certificate... info Certificate generated. Location is C:\Users\mike\AppData\Roaming\npm\node_modules\powerbi-visuals-tools\certs\PowerBICustomVisualTest_public.pfx. Passphrase is '4492518445773821' info Start preparing plugin template info Finish preparing plugin template error error:0308010C:digital envelope routines::unsupported C:\Users\mike\AppData\Roaming\npm\node_modules\powerbi-visuals-tools\node_modules\powerbi-visuals-webpack-plugin\index.js:185 throw new Error("Failed to generate visualPlugin.ts"); ^

Error: Failed to generate visualPlugin.ts at C:\Users\mike\AppData\Roaming\npm\node_modules\powerbi-visuals-tools\node_modules\powerbi-visuals-webpack-plugin\index.js:185:12 at async PowerBICustomVisualsWebpackPlugin._beforeCompile (C:\Users\mike\AppData\Roaming\npm\node_modules\powerbi-visuals-tools\node_modules\powerbi-visuals-webpack-plugin\index.js:177:4)

Node.js v17.0.0

I've tried uninstalling, reatarting and various incantations, but it doesn't want to go.

Is my certificate really invalid? How do I check it? Are there any diagnostics I can run? Any and all advice gladly accepted

I just updated to pbiviz -V 3.4.1 same problem

CodePudding user response:

After a debug session we found an error in [email protected] where the check for certificate in certificatetoosl.js uses the text date of the certificate expiry date, whihc in my case is dd/mm/yyyy which fails because this expects and ISO 8601, but will work with mm/dd/yyyy [![debug image][1]][1] This is the code:

// For Windows OS:
        if (os.platform() === "win32") {
            if (!fs.existsSync(pfxPath) || !passphrase) {
                return false;
            }
            let certStr = await exec(`certutil -p ${passphrase} -dump "${pfxPath}"`);
            let certStrSplitted = certStr.split('\r\n');
            let regex = /(?<=: ).*/;
            endDateStr = regex.exec(certStrSplitted[6]);

        }
        // For Linux and Mac/darwin OS:
        else if (os.platform() === "linux" || os.platform() === "darwin") {
            if (!fs.existsSync(certPath)) {
                return false;
            }
            endDateStr = await exec(`openssl x509 -enddate -noout -in ${certPath} | cut -d = -f 2`);
        }

        let endDate = new Date(Date.parse(endDateStr));
        verifyCertDate = (endDate - new Date()) > certSafePeriod;
        if (verifyCertDate) {
            ConsoleWriter.info(`Certificate is valid.`);
        } else {
            ConsoleWriter.warn(`Certificate is invalid!`);
            removeCertFiles(certPath, keyPath, pfxPath);
        }

We don't have a full solution but there will be workarounds until the package is fixed. Deleting all the modules and reinstalling seemed to fix the visualPlugin.ts problem as well. [1]: https://i.stack.imgur.com/XVrsQ.png

  • Related