OfficeDev / generator-office

Yeoman generator for building Microsoft Office related projects.
https://www.npmjs.com/package/generator-office
MIT License
819 stars 207 forks source link

Compilation of fixes for invalid security certificate error #745

Closed adehad closed 1 year ago

adehad commented 1 year ago

[Just wanted to compile some of the errors across various issue trackers with keywords and error messages as text to hopefully make it easier when searching for the solution to this.]

Prerequisites

Please answer the following questions before submitting an issue.

Expected behavior

Using the vscode debug command to run the add-in I receive a security related error.

I can confirm I can go into edge and manually go to the webpage https://localhost:3000/taskpane.html

But I get the classic security warning.

Add-in Error
The content is blocked because it isn't signed by a valid security certificate.
Add-in Error
Something went wrong and we couldn't start this add-in. 
Please try again later or contact your system administrator.

I do not receive any pop-up confirming whether I want to install any certificates.

Current behavior

image

The image above is capturing as much debug information as I could find based on various issues and posts. Once I press OK on the pop-up is when the error message appears.

I can additionally provide this terminal output (Admin terminal):

> npx office-addin-dev-certs install                                                                                         
The developer certificates have been generated in C:\Users\Ade Had\.office-addin-dev-certs
Installing CA certificate "Developer CA for Microsoft Office Add-ins"...
You now have trusted access to https://localhost.
Certificate: C:\Users\Ade Had\.office-addin-dev-certs\localhost.crt
Key: C:\Users\Ade Had\.office-addin-dev-certs\localhost.key

> npx office-addin-dev-certs verify                                                                                                                                                                                                      
You need to install certificates for trusted access to https://localhost.

>  npx office-addin-dev-certs --version
0.0.1
# Checking the package-lock.json gives the correct version:
# "node_modules/office-addin-dev-certs": {
#      "version": "1.9.3",

I can additionally confirm - to supplement the screenshot. That the "Trusted Root Certificate Authorities" does not contain any expired localhost certs.

I am wondering if this is related to my user account having a space in the name? But I see according to https://github.com/OfficeDev/Office-Addin-Scripts/issues/229 it should be fixed

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. npm install -g yo@4.3.1
  2. npm install generator-office@1.9.2
  3. yo office --projectType react --name "PowerPoint Toolbar" --host powerpoint --ts true
  4. Moved to the folder and ran npm install
  5. Used vscode to run the PowerPoint Desktop (Edge Chromium) debug task

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

Please include any relevant log snippets, screenshots or code samples here.

Pending Items to try

Some options from the linked issues I don't want to try just yet, as I think it would be great if the package worked out of the box and perhaps there is something to learn.

  1. Manually Installing certificate into the trusted store - as the certificate generated only lasts 1month, and ideally I want a 'set and forget' config
  2. Manually modifying the config to point to the right certs: https://github.com/OfficeDev/generator-office/issues/486#issuecomment-528950430
  3. just generated my own certs via: https://stackoverflow.com/questions/8169999/how-can-i-create-a-self-signed-cert-for-localhost or https://stackoverflow.com/questions/21397809/create-a-trusted-self-signed-ssl-cert-for-localhost-for-use-with-express-node Although likely to work I would like to see if there is a way this can work out of the box better.
adehad commented 1 year ago

Probably worth mentioning that the following can be done:

npx office-addin-dev-certs install --days 3000

and then manually installing the certificates would be a 'set and forget' config

millerds commented 1 year ago

A new package with updated certificate management scripts was published. Can you try again with the updated package and see if you still encounter these problems?