From 8e1510ec694db804b32f0696ffe4f15a433dcd20 Mon Sep 17 00:00:00 2001 From: Nate Ferrell Date: Sun, 29 Dec 2019 03:26:38 -0600 Subject: [PATCH] !deploy v2.35.1 ## 2.35.1 - 2019-12-29 * [Issue #57](https://github.com/scrthq/PSGSuite/issues/57) * Updated `New-GSGmailSMIMEInfo` to cast `Pkcs12` to URLSafeBase64 *without* removing the trailing padding `=`, based on GAMs process in Python. Confirmed replication of the resultant value being sent from GAM in PowerShell, ready to validate. --- CHANGELOG.md | 6 ++++++ PSGSuite/PSGSuite.psd1 | 2 +- PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1 | 17 ++++++----------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af67d5f..c1240fd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ * [PSGSuite - ChangeLog](#psgsuite---changelog) + * [2.35.1 - 2019-12-29](#2351---2019-12-29) * [2.35.0 - 2019-12-29](#2350---2019-12-29) * [2.34.0 - 2019-11-02](#2340---2019-11-02) * [2.33.2 - 2019-10-06](#2332---2019-10-06) @@ -105,6 +106,11 @@ # PSGSuite - ChangeLog +## 2.35.1 - 2019-12-29 + +* [Issue #57](https://github.com/scrthq/PSGSuite/issues/57) + * Updated `New-GSGmailSMIMEInfo` to cast `Pkcs12` to URLSafeBase64 *without* removing the trailing padding `=`, based on GAMs process in Python. Confirmed replication of the resultant value being sent from GAM in PowerShell, ready to validate. + ## 2.35.0 - 2019-12-29 * [Issue #216](https://github.com/scrthq/PSGSuite/issues/216) - _Thank you, [@WJurecki](https://github.com/WJurecki)!_ diff --git a/PSGSuite/PSGSuite.psd1 b/PSGSuite/PSGSuite.psd1 index ee0f79d1..054ea76a 100644 --- a/PSGSuite/PSGSuite.psd1 +++ b/PSGSuite/PSGSuite.psd1 @@ -12,7 +12,7 @@ RootModule = 'PSGSuite.psm1' # Version number of this module. - ModuleVersion = '2.35.0' + ModuleVersion = '2.35.1' # ID used to uniquely identify this module GUID = '9d751152-e83e-40bb-a6db-4c329092aaec' diff --git a/PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1 b/PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1 index 72ae80dc..56a3f34c 100644 --- a/PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1 +++ b/PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1 @@ -60,12 +60,7 @@ function New-GSGmailSMIMEInfo { $User ) Process { - if ($User -ceq 'me') { - $User = $Script:PSGSuite.AdminEmail - } - elseif ($User -notlike "*@*.*") { - $User = "$($User)@$($Script:PSGSuite.Domain)" - } + Resolve-Email ([Ref]$User) $serviceParams = @{ Scope = 'https://www.googleapis.com/auth/gmail.settings.basic' ServiceType = 'Google.Apis.Gmail.v1.GmailService' @@ -77,12 +72,13 @@ function New-GSGmailSMIMEInfo { foreach ($key in $PSBoundParameters.Keys | Where-Object {$body.PSObject.Properties.Name -contains $_}) { switch ($key) { EncryptedKeyPassword { - $body.$key = (New-Object PSCredential "user",$PSBoundParameters[$key]).GetNetworkCredential().Password + $pw = (New-Object PSCredential "user",$PSBoundParameters[$key]).GetNetworkCredential().Password + $body.EncryptedKeyPassword = $pw } Pkcs12 { - ###$p12String = Convert-Base64 -From NormalString -To WebSafeBase64String -String "$([System.IO.File]::ReadAllText((Resolve-Path $PSBoundParameters[$key]).Path))" - ###$body.$key = $p12String - $body.$key = [string]([System.IO.File]::ReadAllBytes((Resolve-Path $PSBoundParameters[$key]).Path)) + $pkcs12Content = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($Pkcs12)) + $urlSafePkcs12Content = $pkcs12Content.Replace('+', '-').Replace('/', '_') + $body.Pkcs12 = $urlSafePkcs12Content } Default { $body.$key = $PSBoundParameters[$key] @@ -90,7 +86,6 @@ function New-GSGmailSMIMEInfo { } } Write-Verbose "Adding new S/MIME of SendAsEmail '$SendAsEmail' for user '$User' using Certificate '$Pkcs12'" - Write-Verbose "Pkcs12: $($body.Pkcs12)" $request = $service.Users.Settings.SendAs.SmimeInfo.Insert($body,$User,$SendAsEmail) $request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru }