Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dev certs for mac #245

Closed

Conversation

TCourtneyOwen
Copy link
Contributor

With these changes, on Mac we will check to see if the dev-cert exists first. If it does, we will subsequently see if it's expired and if that's the case uninstall the certs.

I did local testing and this seems to work well, but it might be good to get some other eyes on it

@TCourtneyOwen TCourtneyOwen requested a review from a team as a code owner January 17, 2020 00:09
return true;
// Ceritificate exists. Now check and see if it's expired and remove it if is.
try {
const command = `security find-certificate -c '${defaults.certificateName}' -p | openssl x509 -checkend 86400 -noout`;
Copy link
Contributor

@akrantz akrantz Jan 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this try/catch into a function isCaCertificateExpired() which returns a boolean, and then have the code here be:

// on Mac, remove certificate if expired
if (process.platform === darwin) {
if (isCaCertificateExpired()) {
uninstallExpiredCertificate();
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My biggest concern with this is that the isCaCertificateInstalled() function is adding a side-effect which removes a cert. That really shouldn't be done inside this function as a side-effect. Is there a way to move this out of this function and call it for mac from another place?

}
}
}

// Currently this method is only intended to be used for Mac due to problems on Mac that occur when CA certificates expire
export async function uninstallExpiredCaCertificate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't export this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I don't think you need this function at all. The uninstall command is the same and the message doesn't need to say whether it is expired. can't you just use the regular uninstallCaCertificate() function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't use the regular uninstallCaCertificate because it calls isCaCertificateInstalled, which will then get us in an endless loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I initially had uninstallCaCertificate take a Boolean expiredCert param so we could bypass the call to isCaCertificateInstalled for the removing of an expired cert

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to add an optional param "expiredOnly = false" to uninstallCaCertificate() which could be called with expiredOnly as true for Mac?

@hyacinthus
Copy link

What's new about this pr?

This issue is annoyed in Mac.

@millerds
Copy link
Contributor

millerds commented Dec 2, 2021

Did a different fix in more up to date repo.

@millerds millerds closed this Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

office-addin-dev-certs: keeps adding new certs on mac
5 participants