Skip to content

Commit 985a79b

Browse files
Merge pull request #17202 from miminar/signature-workflow-reenabled-15809
Automatic merge from submit-queue. verify-signature: fixed (in)secure transport And reenabled image signature workflow extended test. Resolves #15809
2 parents a604dc4 + 262b8ba commit 985a79b

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

pkg/oc/admin/image/manifest.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77

88
"github.com/docker/distribution/digest"
99

10+
"k8s.io/client-go/rest"
11+
1012
"github.com/openshift/origin/pkg/image/importer"
1113
)
1214

@@ -18,7 +20,12 @@ func getImageManifestByIDFromRegistry(registry *url.URL, repositoryName, imageID
1820
credentials := importer.NewBasicCredentials()
1921
credentials.Add(registry, username, password)
2022

21-
repo, err := importer.NewContext(http.DefaultTransport, http.DefaultTransport).
23+
insecureRT, err := rest.TransportFor(&rest.Config{TLSClientConfig: rest.TLSClientConfig{Insecure: true}})
24+
if err != nil {
25+
return nil, err
26+
}
27+
28+
repo, err := importer.NewContext(http.DefaultTransport, insecureRT).
2229
WithCredentials(credentials).
2330
Repository(ctx, registry, repositoryName, insecure)
2431
if err != nil {

pkg/oc/admin/image/verify-signature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func (o *VerifyImageSignatureOptions) getImageManifest(img *imageapi.Image) ([]b
256256
if len(o.RegistryURL) > 0 {
257257
registryURL = &url.URL{Host: o.RegistryURL, Scheme: "https"}
258258
if o.Insecure {
259-
registryURL.Scheme = "http"
259+
registryURL.Scheme = ""
260260
}
261261
}
262262
return getImageManifestByIDFromRegistry(registryURL, parsed.RepositoryName(), img.Name, o.CurrentUser, o.CurrentUserToken, o.Insecure)

test/extended/registry/signature.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package registry
22

33
import (
44
"fmt"
5+
"strings"
56

67
g "github.com/onsi/ginkgo"
78
o "github.com/onsi/gomega"
@@ -12,7 +13,7 @@ import (
1213
e2e "k8s.io/kubernetes/test/e2e/framework"
1314
)
1415

15-
var _ = g.Describe("[imageapis][registry][Skipped][Serial] image signature workflow", func() {
16+
var _ = g.Describe("[imageapis][registry][Serial] image signature workflow", func() {
1617

1718
defer g.GinkgoRecover()
1819

@@ -22,7 +23,6 @@ var _ = g.Describe("[imageapis][registry][Skipped][Serial] image signature workf
2223
)
2324

2425
g.It("can push a signed image to openshift registry and verify it", func() {
25-
g.Skip("FIXME: fix oadm verify-image-signature to work with secured registry")
2626
g.By("building a signer image that knows how to sign images")
2727
output, err := oc.Run("create").Args("-f", signerBuildFixture).Output()
2828
if err != nil {
@@ -86,8 +86,17 @@ var _ = g.Describe("[imageapis][registry][Skipped][Serial] image signature workf
8686
// Sign and copy the origin-pod image into target image stream tag
8787
// TODO: Fix skopeo to pickup the Kubernetes environment variables (remove the $KUBERNETES_MASTER)
8888
g.By("signing the origin-pod:latest image and pushing it into openshift registry")
89-
_, err = pod.Exec("KUBERNETES_MASTER=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT GNUPGHOME=/var/lib/origin/gnupg " +
90-
"skopeo --debug --tls-verify=false copy --sign-by [email protected] --dest-creds " + user + ":" + token + " --dest-tls-verify=false docker://docker.io/openshift/origin-pod:latest atomic:" + signedImage)
89+
out, err = pod.Exec(strings.Join([]string{
90+
"KUBERNETES_MASTER=https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_SERVICE_PORT",
91+
"GNUPGHOME=/var/lib/origin/gnupg",
92+
"skopeo", "--debug", "copy", "--sign-by", "[email protected]",
93+
"--dest-creds=" + user + ":" + token,
94+
// TODO: test with this turned to true as well
95+
"--dest-tls-verify=false",
96+
"docker://docker.io/openshift/origin-pod:latest",
97+
"atomic:" + signedImage,
98+
}, " "))
99+
fmt.Fprintf(g.GinkgoWriter, "output: %s\n", out)
91100
o.Expect(err).NotTo(o.HaveOccurred())
92101

93102
err = exutil.WaitForAnImageStreamTag(oc, oc.Namespace(), "signed", "latest")
@@ -102,8 +111,16 @@ var _ = g.Describe("[imageapis][registry][Skipped][Serial] image signature workf
102111
o.Expect(err).NotTo(o.HaveOccurred())
103112
o.Expect(out).To(o.ContainSubstring("Unverified"))
104113

105-
out, err = pod.Exec("GNUPGHOME=/var/lib/origin/gnupg " +
106-
"oc adm verify-image-signature " + imageName + " --expected-identity=" + signedImage + " --save")
114+
out, err = pod.Exec(strings.Join([]string{
115+
"GNUPGHOME=/var/lib/origin/gnupg",
116+
"oc", "adm", "verify-image-signature",
117+
"--insecure=true", // TODO: import the ca certificate into the signing pod
118+
"--loglevel=5",
119+
imageName,
120+
"--expected-identity=" + signedImage,
121+
" --save",
122+
}, " "))
123+
fmt.Fprintf(g.GinkgoWriter, "output: %s\n", out)
107124
o.Expect(err).NotTo(o.HaveOccurred())
108125
o.Expect(out).To(o.ContainSubstring("identity is now confirmed"))
109126

0 commit comments

Comments
 (0)