...
1# Copyright 2021 The Sigstore Authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15function New-TmpDir {
16 $parent = [System.IO.Path]::GetTempPath()
17 $name = [System.IO.Path]::GetRandomFileName()
18 New-Item -ItemType Directory -Path (Join-Path $parent $name)
19}
20
21make cosign
22$TmpDir = New-TmpDir
23Copy-Item -Path .\cosign -Destination (Join-Path $TmpDir cosign.exe)
24
25Push-Location $TmpDir
26
27# See if things blow up immediately
28.\cosign.exe version
29
30# Generate a random alphanumeric password for the private key
31$pass = Get-Random
32
33Write-Output $pass | .\cosign.exe generate-key-pair
34$signing_key = "cosign.key"
35$verification_key = "cosign.pub"
36
37$test_img = "ghcr.io/distroless/static"
38Write-Output $pass | .\cosign.exe sign --key $signing_key --output-signature interactive.sig --output-payload interactive.payload --tlog-upload=false $test_img
39.\cosign.exe verify --key $verification_key --signature interactive.sig --payload interactive.payload --insecure-ignore-tlog=true $test_img
40
41Pop-Location
42
43Write-Output "Success"
View as plain text