Skip to content

Commit 8e1510e

Browse files
committed
!deploy v2.35.1
## 2.35.1 - 2019-12-29 * [Issue #57](#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.
1 parent 82bee3b commit 8e1510e

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* [PSGSuite - ChangeLog](#psgsuite---changelog)
2+
* [2.35.1 - 2019-12-29](#2351---2019-12-29)
23
* [2.35.0 - 2019-12-29](#2350---2019-12-29)
34
* [2.34.0 - 2019-11-02](#2340---2019-11-02)
45
* [2.33.2 - 2019-10-06](#2332---2019-10-06)
@@ -105,6 +106,11 @@
105106

106107
# PSGSuite - ChangeLog
107108

109+
## 2.35.1 - 2019-12-29
110+
111+
* [Issue #57](https://github.com/scrthq/PSGSuite/issues/57)
112+
* 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.
113+
108114
## 2.35.0 - 2019-12-29
109115

110116
* [Issue #216](https://github.com/scrthq/PSGSuite/issues/216) - _Thank you, [@WJurecki](https://github.com/WJurecki)!_

PSGSuite/PSGSuite.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSGSuite.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.35.0'
15+
ModuleVersion = '2.35.1'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'

PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1

+6-11
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@ function New-GSGmailSMIMEInfo {
6060
$User
6161
)
6262
Process {
63-
if ($User -ceq 'me') {
64-
$User = $Script:PSGSuite.AdminEmail
65-
}
66-
elseif ($User -notlike "*@*.*") {
67-
$User = "$($User)@$($Script:PSGSuite.Domain)"
68-
}
63+
Resolve-Email ([Ref]$User)
6964
$serviceParams = @{
7065
Scope = 'https://www.googleapis.com/auth/gmail.settings.basic'
7166
ServiceType = 'Google.Apis.Gmail.v1.GmailService'
@@ -77,20 +72,20 @@ function New-GSGmailSMIMEInfo {
7772
foreach ($key in $PSBoundParameters.Keys | Where-Object {$body.PSObject.Properties.Name -contains $_}) {
7873
switch ($key) {
7974
EncryptedKeyPassword {
80-
$body.$key = (New-Object PSCredential "user",$PSBoundParameters[$key]).GetNetworkCredential().Password
75+
$pw = (New-Object PSCredential "user",$PSBoundParameters[$key]).GetNetworkCredential().Password
76+
$body.EncryptedKeyPassword = $pw
8177
}
8278
Pkcs12 {
83-
###$p12String = Convert-Base64 -From NormalString -To WebSafeBase64String -String "$([System.IO.File]::ReadAllText((Resolve-Path $PSBoundParameters[$key]).Path))"
84-
###$body.$key = $p12String
85-
$body.$key = [string]([System.IO.File]::ReadAllBytes((Resolve-Path $PSBoundParameters[$key]).Path))
79+
$pkcs12Content = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($Pkcs12))
80+
$urlSafePkcs12Content = $pkcs12Content.Replace('+', '-').Replace('/', '_')
81+
$body.Pkcs12 = $urlSafePkcs12Content
8682
}
8783
Default {
8884
$body.$key = $PSBoundParameters[$key]
8985
}
9086
}
9187
}
9288
Write-Verbose "Adding new S/MIME of SendAsEmail '$SendAsEmail' for user '$User' using Certificate '$Pkcs12'"
93-
Write-Verbose "Pkcs12: $($body.Pkcs12)"
9489
$request = $service.Users.Settings.SendAs.SmimeInfo.Insert($body,$User,$SendAsEmail)
9590
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
9691
}

0 commit comments

Comments
 (0)