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 Set-DbaNetworkCertificate not granting permissions to private key #5417

Merged
merged 1 commit into from
Apr 27, 2019
Merged

Conversation

maddhatter
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes #)
  • New feature (non-breaking change, adds functionality)
  • Breaking change (effects multiple commands or functionality)
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

On a Windows Server 2016 (version 1607, Build 1439.2848) server, Set-DbaNetworkCertificate does not grant permissions to the private key.

Approach

This appears to be because the PrivateKey property of the certificate is $null, and the PrivateKey is used to populate the path to the underlying certificate file.

Added a check to see if PrivateKey is null, and if it is use a different method to determine the underlying file. Also added a check to be sure that $KeyFullPath is a valid path to a file and abort if it isn't.

Commands to test

# On a Windows 2016 box (I'm using a newly provisioned Azure IaaS server built from the SQL Server 2017 marketplace image)
Set-DbaNetworkCertificate -Certificate $cert

Screenshots

Learning

@potatoqualitee
Copy link
Member

awesome solution, thank you! will merge when tests pass :bowtie:

@potatoqualitee potatoqualitee merged commit e39c62c into dataplat:development Apr 27, 2019
@potatoqualitee
Copy link
Member

🎉 🎉 🎉

@maddhatter maddhatter deleted the netcert branch July 26, 2019 13:58
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.

2 participants