OfficeDev / Office-Addin-Scripts

A set of scripts and packages that are consumed in Office add-ins projects.
MIT License
152 stars 93 forks source link

why is the exception ignored when executing "certs verify" command? #828

Closed Code-Agitator closed 5 months ago

Code-Agitator commented 5 months ago

Prerequisites

image

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

Expected behavior

Current behavior

Cowjiang commented 5 months ago

I encountered a scenario where certificate check failed via office-addin-dev-certs due to an OpenSSL error.

Reproduce:

  1. disabled OpenSSL or remove it
  2. install dev certs
  3. run office-addin-dev-certs verify

Then you will got 'pls install trusted certs....'

Per checked, this line: if [ 0 -lt $(echo "$cert" | openssl x509 -checkend 86400 | grep -c "will not expire") ]; then throw an error by OpenSSL. However, it will ignore the error thrown by the script's process as @Code-Agitator mentioned.

millerds commented 5 months ago

Per the comment in the code shown in the screen shot, in some cases (this has to work across different platforms) exceptions are thrown when the certificate is just not installed as opposed to an error when trying to check. The message returned indicates the certificate needs to be installed which is correct in those exception cases.

However, you bring up a valid point that an exception isn't always going to simply be a lack of the certificate being installed. It would be nice to at least provide some output showing what was going on and possibly distinguish between a "missing cert" exception and something else.

Thanks for reporting this. I have added a work item to our backlog (internal id 8677374), but we cannot provide and estimate for when we might get to this. Feel free to submit a PR with a fix for our consideration if you don't feel like waiting.