-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #this script reads the sealer key configuration from the IdP's idp.properties file and rotates the sealer key | ||
| Try { | ||
| $runthis = $env:ENABLE_SEALER_KEY_ROTATION | ||
| } | ||
| Catch { | ||
| $runthis = 'True' | ||
| } | ||
|
|
||
| If ($runthis -eq 'True') { | ||
| #settings | ||
| $IDP_HOME="c:\opt\shibboleth-idp" | ||
| $IDPPROP=$IDP_HOME + "\conf\idp.properties" | ||
| $JAVA_HOME="c:\zulujava\zulu-8" | ||
| #item below is only used if you have configured additional hosts to sync your sealer to | ||
| $SYNC_CRED="domain\user" | ||
|
|
||
| #get config from properties file | ||
| $storefile = (cat $IDPPROP | where { $_ -match "idp.sealer.storeResource"}).Split("=")[1].Trim().Replace("%{idp.home}", $IDP_HOME).Replace("/","\") | ||
| $versionfile = (cat $IDPPROP | where { $_ -match "idp.sealer.versionResource"}).Split("=")[1].Trim().Replace("%{idp.home}", $IDP_HOME).Replace("/","\") | ||
| $storepass = (cat $IDPPROP | where { $_ -match "idp.sealer.storePassword"}).Split("=")[1].Trim().Replace("{","`{").Replace("}","`}") | ||
| $alias = (cat $IDPPROP | where { $_ -match "idp.sealer.aliasBase"}).Split("=")[1].Trim() | ||
| try { | ||
| $count = (cat $IDPPROP | where { $_ -match "idp.sealer._count"}).Split("=")[1].Trim() | ||
| } | ||
| catch { | ||
| $count = 30 | ||
| } | ||
| try { | ||
| $sync_hosts = (cat $IDPPROP | where { $_ -match "idp.sealer._sync_hosts"}).Split("=")[1].Trim() | ||
| } | ||
| catch { | ||
| $sync_hosts = $env:COMPUTERNAME | ||
| } | ||
|
|
||
|
|
||
| #Write-Host "Keystore:" $storefile | ||
| #Write-Host "Version File:" $versionfile | ||
| #Write-Host "Store Pass:" $storepass | ||
| #Write-Host "Alias:" $alias | ||
| #Write-Host "Count:" $count | ||
| #Write-Host "Sync Hosts:" $sync_hosts | ||
|
|
||
| #rotate key | ||
| $cmd = "${IDP_HOME}\bin\runclass.bat net.shibboleth.utilities.java.support.security.BasicKeystoreKeyStrategyTool --storefile $storefile --storepass `$storepass --versionfile $versionfile --alias $alias --count $count" | ||
| Invoke-Expression $cmd | ||
|
|
||
| #display current/new version | ||
| Write-Host "Current Key Version:" (cat $versionfile).split("=")[2].Trim() | ||
|
|
||
| #sync to other hosts | ||
| $sync_hosts.split(" ") | ForEach { | ||
| If ($_.Trim() = $env:COMPUTERNAME) {Write-Host "***skipping sync to local host"} Else { | ||
| Write-Host "Syncing to: $_" | ||
| $Session = New-PSSession -ComputerName "$_" -Credential $SYNC_CRED | ||
| Copy-Item $versionfile -Destination $IDP_HOME\credentials -ToSession $Session | ||
| } | ||
| } | ||
|
|
||
| } |