You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix certificate handling and permissions issues across multiple commands (#5433)
* Fix certificate handling and permissions issues across multiple commands
* Fix certificate handling and permissions issues in various commands
* Fix key container name retrieval and improve file permission handling in certificate operations
* Fix key container name retrieval and ensure proper disposal of RSA private keys
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
27
27
- Changed `Export-PnPFlow -AsZipPackage` and `Export-PnPPowerApp` to ask for confirmation before overwriting an existing file when `-OutPath` is omitted, as they already did when `-OutPath` is specified. Unattended scripts that rely on the previous silent overwrite need to specify `-Force`. [#5421](https://github.com/pnp/powershell/pull/5421)
28
28
29
29
### Fixed
30
+
- Fixed `Disconnect-PnPOnline` never removing the private key container which loading a certificate leaves behind, so every certificate based connect permanently added a private key file to the profile of the user. Certificates are loaded with `X509KeyStorageFlags.UserKeySet`, which places the key container under `%APPDATA%\Microsoft\Crypto`, while only the machine wide `%ProgramData%\Microsoft\Crypto\RSA\MachineKeys` was looked at, so the removal silently found nothing to do. Both locations are now checked, `Connect-PnPOnline -CertificateBase64Encoded` takes part in the cleanup as `-CertificatePath` already did, and a removal which does not succeed is written to the debug log rather than being swallowed. [#5433](https://github.com/pnp/powershell/pull/5433)
31
+
- Fixed `New-PnPAzureCertificate -OutPfx` and `Register-PnPEntraIDApp -OutPath` writing the PFX holding the private key using the default permissions of the process on Linux and macOS, which the usual umask leaves readable by every local account. The file is now created readable and writable by its owner only. The accompanying CER file holds no private key and keeps the default permissions. [#5433](https://github.com/pnp/powershell/pull/5433)
32
+
- Fixed `Connect-PnPOnline -CertificatePath` keeping the certificate file open for as long as the PowerShell session lived, which prevented the file from being moved, replaced or deleted and leaked a file handle on every connect. The same read could also return fewer bytes than the file holds and have the resulting truncated certificate reported as being corrupt or password protected. [#5433](https://github.com/pnp/powershell/pull/5433)
33
+
- Fixed `Get-PnPTenantDeletedSite` failing to fetch the additional details of a site whose url contains an ampersand, as the url was placed into the CAML query without being escaped. [#5433](https://github.com/pnp/powershell/pull/5433)
34
+
- Fixed `Get-PnPListItemAttachment` combining the file name returned by the server with `-Path` without reducing it to its file name part first, which meant a rooted value would have silently replaced the path that was asked for. [#5433](https://github.com/pnp/powershell/pull/5433)
30
35
- Fixed delegated and application permission metadata and documentation for `Add-PnPPlannerBucket`, `Add-PnPPlannerRoster`, `Add-PnPPlannerRosterMember`, `Add-PnPPlannerTask`, `Get-PnPPlannerBucket`, `Get-PnPPlannerPlan`, `Get-PnPPlannerRosterMember`, `Get-PnPPlannerRosterPlan`, `Get-PnPPlannerTask`, `New-PnPPlannerPlan`, `Remove-PnPPlannerBucket`, `Remove-PnPPlannerPlan`, `Remove-PnPPlannerRoster`, `Remove-PnPPlannerRosterMember`, `Remove-PnPPlannerTask`, `Set-PnPPlannerBucket`, `Set-PnPPlannerPlan`, and `Set-PnPPlannerTask`. [#5432](https://github.com/pnp/powershell/pull/5432)
31
36
- Fixed delegated and application permission metadata and documentation for `Add-PnPTodoTaskFileAttachment`, `Get-PnPTodoList`, `Get-PnPTodoTask`, `Get-PnPTodoTaskChecklistItem`, `Get-PnPTodoTaskFileAttachment`, `Get-PnPTodoTaskLinkedResource`, `New-PnPTodoList`, `New-PnPTodoTask`, `New-PnPTodoTaskChecklistItem`, `New-PnPTodoTaskLinkedResource`, `Remove-PnPTodoList`, `Remove-PnPTodoTask`, `Remove-PnPTodoTaskChecklistItem`, `Remove-PnPTodoTaskFileAttachment`, `Remove-PnPTodoTaskLinkedResource`, `Update-PnPTodoList`, `Update-PnPTodoTask`, and `Update-PnPTodoTaskChecklistItem`. [#5432](https://github.com/pnp/powershell/pull/5432)
32
37
- Changed Microsoft To Do cmdlets to target the user supplied through `-User` directly, avoiding an additional Microsoft Graph user lookup and correctly encoding guest user principal names. Invalid user identifiers now surface the Microsoft Graph error returned by the To Do endpoint instead of being silently ignored. [#5432](https://github.com/pnp/powershell/pull/5432)
// Best effort cleanup, but no longer silent so that a failure to remove the key can be diagnosed
1127
+
Log.Debug("PnPConnection",$"Unable to remove the private key container of the certificate at '{candidatePath}': {e.Message}");
1081
1128
}
1082
1129
}
1083
-
catch(Exception)
1084
-
{
1085
-
// best effort cleanup
1086
-
}
1130
+
1131
+
Log.Debug("PnPConnection",$"The private key container '{uniqueKeyContainerName}' of the certificate was not found in any of the known locations, so nothing was removed.");
Log.Debug("CertificateHelper",$"Opening certificate in file '{certificatePath}' {(certificatePassword==null?"without":"using")} a certificate password");
0 commit comments