Skip to content

Commit

Permalink
!deploy v2.35.1
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
scrthq committed Dec 29, 2019
1 parent 82bee3b commit 8e1510e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)!_
Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
17 changes: 6 additions & 11 deletions PSGSuite/Public/Gmail/New-GSGmailSMIMEInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -77,20 +72,20 @@ 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]
}
}
}
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
}
Expand Down

0 comments on commit 8e1510e

Please sign in to comment.