]> apps.delaporte.us Git - dotfiles.git/blob - psmodules/sign.psm1
Local user code singing utils.
[dotfiles.git] / psmodules / sign.psm1
1 <#
2 .SYNPOSIS
3
4 Commands to maintain a local code singing cert.
5
6 #>
7 $certName = "Local Code Sign Cert"
8 $codeSigning = ""
9
10 function New-CodeSignCert {
11 $cert = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject $certName -KeyAlgorithm RSA -KeyLength 2048 -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -KeyUsage "DigitalSignature"
12
13 }
14
15 function Get-CodeSignCert {
16 $certName = "Local Code Sign Cert"
17 return Get-ChildItem -Path Cert:\CurrentUser\My | Select-Object -First 1
18 # | ? Subject -EQ "CN=$certName"
19 }
20
21 function Install-CodeSignCert {
22
23 $cert = Get-CodeSignCert
24 Move-Item -Path $cert.PSPath -Destination "Cert:\CurrentUser\Root"
25 }
26
27 function Invoke-CodeSign {
28 param(
29 [string]$Path
30 )
31 $cert = Get-CodeSignCert
32 Set-AuthenticodeSignature -FilePath $Path -Certificate $cert
33 }
34
35 Invoke-CodeSignProfile {
36 Invoke-CodeSign -Path $profile
37 }
38
39 Export-ModuleMember -Function New-CodeSignCert
40 Export-ModuleMember -Function Get-CodeSignCert
41 Export-ModuleMember -Function Install-CodeSignCert
42 Export-ModuleMember -Function Invoke-CodeSign
43 Export-ModuleMember -Function Invoke-CodeSignProfile