Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Signify service to use mTLS #11777

Merged
merged 55 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b1bb1ac
x
akiioto Sep 4, 2024
4cf206b
x
akiioto Sep 4, 2024
3d68a36
x
akiioto Sep 4, 2024
7e4e8c2
x
akiioto Sep 4, 2024
7deacb0
x
akiioto Sep 4, 2024
d2ef838
cert probably working
akiioto Sep 5, 2024
bcf7cc1
test
akiioto Sep 5, 2024
756c011
Merge branch 'main' into test_mtls2
akiioto Sep 5, 2024
f6047c1
build
akiioto Sep 5, 2024
c868b05
use decrypted key
akiioto Sep 6, 2024
d4a6196
rew
akiioto Sep 6, 2024
11bd36b
go mod
akiioto Sep 6, 2024
3b97536
rew
akiioto Sep 6, 2024
47b724c
rev
akiioto Sep 6, 2024
bac1067
rev
akiioto Sep 6, 2024
1c0d045
revert
akiioto Sep 6, 2024
3a372ac
adjust to review
akiioto Sep 10, 2024
1a6afc1
adjust to review
akiioto Sep 10, 2024
8e8e8b1
test for cert
akiioto Sep 11, 2024
d6a65b4
notary tests, refactor to test
akiioto Sep 12, 2024
0f3ed70
notary tests, refactor to test
akiioto Sep 12, 2024
62363ad
linters
akiioto Sep 12, 2024
48ad56f
linters
akiioto Sep 12, 2024
ab4e827
working
akiioto Sep 12, 2024
f969801
upd8 test
akiioto Sep 13, 2024
6b1523c
upd8 test
akiioto Sep 13, 2024
bf9fb39
upd8 test
akiioto Sep 13, 2024
267514e
Revert "working"
akiioto Sep 13, 2024
2d31ad8
upd8 test
akiioto Sep 13, 2024
2fcb50b
test
akiioto Sep 16, 2024
a1f3fe0
New solution
akiioto Sep 16, 2024
f4141ba
New solution
akiioto Sep 16, 2024
8e6a901
New solution
akiioto Sep 16, 2024
a7a166e
New solution
akiioto Sep 16, 2024
ce89c6f
Ready to review, no hardcodes. 85% test coverage
akiioto Sep 16, 2024
0077dc8
Change endpoint
akiioto Sep 17, 2024
eacd35e
Change endpoint
akiioto Sep 17, 2024
df64252
remove unused mock
akiioto Sep 17, 2024
7b6c9c5
Apply suggestions from code review
akiioto Sep 17, 2024
b4d9022
minor
akiioto Sep 18, 2024
21987cf
test of interfaces
akiioto Sep 18, 2024
8f3cb55
test updates
akiioto Sep 18, 2024
75600c7
remove last field function
akiioto Sep 18, 2024
a8260b6
delete comments
akiioto Sep 23, 2024
405d22f
renaming stuff
akiioto Sep 24, 2024
378334f
remove tlsconfigratorinterface
akiioto Sep 24, 2024
e703192
adjust tests
akiioto Sep 24, 2024
f496d68
update to decouple external library
akiioto Sep 24, 2024
c881544
cleanup
akiioto Sep 25, 2024
19f1c78
remove redundant status check
akiioto Sep 25, 2024
441012b
remove last variable
akiioto Sep 25, 2024
74f29b4
use buffered tls config
akiioto Sep 25, 2024
f7ca846
fix retryhttp
akiioto Sep 25, 2024
3a40a15
fix test certificate
akiioto Sep 25, 2024
1047003
Make NotarySigner fields private
akiioto Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cmd/image-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ Image signing allows verification that the image comes from a trusted repository
> [!NOTE]
> Image Builder signs images built on the push and workflow_dispatch events only. Images built on the pull_request_target event are not signed.

## Image Signing with Signify

Image Builder signs images using the Signify service, ensuring that images come from trusted repositories and have not been tampered with.

### Updated Signing Process

The authentication to the Signify API has been updated from using `role id/secret id` to mTLS. This change introduces the following updates:

- **mTLS Authentication**: Image Builder now uses a client certificate/private key pair for authentication with the Signify API. These credentials are valid for 7 days, after which they must be rotated.
- **Automated Rotation**: The certificate rotation must occur every 7 days. The new certificate/private key pair must be generated using the previous pair before they expire.

The Signify API's structure has also been updated. For more information, see the official [Signify API Documentation](https://pages.github.tools.sap/Repository-Services/Signify/how_to/manage_signatures/).

> [!NOTE]
> Images are only signed when built on `push` and `workflow_dispatch` events. Pull request images are not signed.

### Signify API Changes

The JSON structure for signing has changed. See the new structure and examples in the [Signify API Documentation](https://pages.github.tools.sap/Repository-Services/Signify/how_to/manage_signatures/).


## Named Tags

Image Builder supports passing the name along with the tag, using both the `-tag` option and the config for the tag template.
Expand Down
21 changes: 14 additions & 7 deletions cmd/image-builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ func Test_getSignersForOrgRepo(t *testing.T) {
for _, c := range tc {
t.Run(c.name, func(t *testing.T) {
t.Setenv("JOB_TYPE", c.jobType)
mockFactory := &mockSignerFactory{}

o := &options{isCI: c.ci, Config: Config{SignConfig: SignConfig{
EnabledSigners: map[string][]string{
"*": {"test-notary"},
Expand All @@ -453,21 +455,22 @@ func Test_getSignersForOrgRepo(t *testing.T) {
{
Name: "test-notary",
Type: sign.TypeNotaryBackend,
Config: sign.NotaryConfig{},
Config: mockFactory,
},
{
Name: "test-notary2",
Type: sign.TypeNotaryBackend,
Config: sign.NotaryConfig{},
Config: mockFactory,
},
{
Name: "ci-notary",
Type: sign.TypeNotaryBackend,
Config: sign.NotaryConfig{},
Config: mockFactory,
JobType: []string{"postsubmit"},
},
},
}}}

got, err := getSignersForOrgRepo(o, c.orgRepo)
if err != nil && !c.expectErr {
t.Errorf("got error but didn't want to %v", err)
Expand Down Expand Up @@ -789,12 +792,16 @@ Build config file content:
}
}

type mockSigner struct {
signFunc func([]string) error
type mockSignerFactory struct{}

func (m *mockSignerFactory) NewSigner() (sign.Signer, error) {
return &mockSigner{}, nil
}

func (m *mockSigner) Sign(images []string) error {
return m.signFunc(images)
type mockSigner struct{}

func (m *mockSigner) Sign([]string) error {
return nil
}

func Test_getDockerfileDirPath(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion configs/kaniko-build-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sign-config:
- postsubmit
- workflow_dispatch
config:
endpoint: https://signing.repositories.cloud.sap/signingsvc/sign
endpoint: https://signing-manage.repositories.cloud.sap/trusted-collections/publish
timeout: 5m
retry-timeout: 10s
secret:
Expand Down
Loading
Loading