Skip to content

[Collections] Signing (part 5): validate signature #3252

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

Closed
wants to merge 18 commits into from

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented Feb 10, 2021

This continues part 4 but doesn't necessarily depend on it.

Modifications:

  • Add PackageCollectionsSigning dependency to PackageCollections module
  • Verify collection signature in JSONPackageCollectionProvider

This is part 1 of a series of PRs to support package collection signing.

Modifications:
- New `PackageCollectionsSigning` module
- Add `Certificate` type
- Add EC and RSA key types
This is part 2 of a series of PRs to support package collection signing.

Depends on [part 1](swiftlang#3241)

Modifications:

Add support for signing with EC and RSA keys
- Introduce `CertificatePolicy` protocol (more on this in part 3)
- `PackageCollectionsSigning` - given a package collection, certificate and its private key, generate a "signed" collection; and reverse that process to validate collection signature.
This is part 3 of a series of PRs to support package collection signing.

Depends on [part 2](swiftlang#3242)

Modifications:
- Certificate policies to validate collection signing certificates. OCSP support on non-Apple platforms to come in part 4.
- Wire up `PackageCollectionSigning` with certificate policies.
This is part 4 of a series of PRs to support package collection signing.

Depends on [part 3](swiftlang#3245)

Modifications:
- Add PackageCollectionsSigningLibc module
- Add OCSP support for non-Apple platforms through PackageCollectionsSigningLibc
This continues [part 4](swiftlang#3250) but doesn't necessarily depend on it.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
@yim-lee
Copy link
Contributor Author

yim-lee commented Feb 10, 2021

@swift-ci please smoke test

certChainPaths: [URL],
certPrivateKeyPath: URL,
certPolicyKey: CertificatePolicyKey,
jsonEncoder: JSONEncoder,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: are we passing a concrete JSONEncoder to save the need to create a new one every time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we passing a concrete JSONEncoder to save the need to create a new one every time?

No, the collection is serialized and embedded inside the signature, and upon checking the signature we deserialize the collection and compare it with the one received. In previous implementations we were comparing JSON/Data so we had to make sure we use the same encoder/decoder, but now that we are comparing SignedCollection we can probably get away with that.

/// - callback: The callback to invoke when the result is available.
func validate(signedCollection: PackageCollectionModel.V1.SignedCollection,
certPolicyKey: CertificatePolicyKey,
jsonDecoder: JSONDecoder,
Copy link
Contributor

@tomerd tomerd Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question as above. seems a bit unnatural to have it in the public API vs. a private static decoder/encoder at the implementation level (imo). fwiw, I would feel differently if this was a "TopLevelEncoder" (which does not exist in the stdlib) that reflect the format can be either JSON or something else, but since its always JSON it feels like this should be an impl detail rather than exposed in the API

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed the "part 5" commit (e23c7e7) only, looks good to me. one question regarding API design

yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Feb 13, 2021
This is part 4 of a series of PRs to support package collection signing on Apple platforms. Originally swiftlang#3252.

Depends on  swiftlang#3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Feb 13, 2021
This is part 4 of a series of PRs to support package collection signing on Apple platforms. Originally swiftlang#3252.

Depends on  swiftlang#3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
@yim-lee
Copy link
Contributor Author

yim-lee commented Feb 13, 2021

Closing this PR, which has been replaced with #3271 and #3272

@yim-lee yim-lee closed this Feb 13, 2021
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Feb 17, 2021
This is part 4 of a series of PRs to support package collection signing on Apple platforms. Originally swiftlang#3252.

Depends on  swiftlang#3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Feb 18, 2021
This is part 4 of a series of PRs to support package collection signing on **Apple** platforms. Originally swiftlang#3252.

Depends on  swiftlang#3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Feb 18, 2021
This is part 4 of a series of PRs to support package collection signing on **Apple** platforms. Originally swiftlang#3252.

Depends on  swiftlang#3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Feb 18, 2021
This is part 4 of a series of PRs to support package collection signing on **Apple** platforms. Originally swiftlang#3252.

Depends on  swiftlang#3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
yim-lee added a commit that referenced this pull request Feb 19, 2021
This is part 4 of a series of PRs to support package collection signing on **Apple** platforms. Originally #3252.

Depends on  #3269.

Modifications:
- Add `PackageCollectionsSigning` dependency to `PackageCollections` module
- Verify collection signature in `JSONPackageCollectionProvider`
- Don't cache CertificatePolicy
- Add support for additionalTrustedRootCerts
- Custom certificate policy by collection source
- Throw cannotVerifySignature when no trusted roots configured
- Feature flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants