Motivation:
Swift 6.1 has been released, we should add it to our CI coverage.
Modifications:
Add additional Swift 6.1 jobs where appropriate in main.yml,
pull_request.yml
Result:
Improved test coverage.
Add capability of converting RDN value of ASN1IA5String to String, if I
am correct all RFC expect that RDN value can be ASN1IA5String..
- additionally fix tests after this change
- added DN components emailAddress(E) and domainComponent(DC)
Warnings as errors is enabled on 5.9, but this is preventing us from
adding visionOS as a platform in our availability guards. Since we're
not regressing anything by doing this, and we're close to dropping
support for 5.9 anyways, we should remove this setting so that we can
support visionOS.
Motivation:
* Improve test coverage
Modifications:
Enable macOS CI to be run on pull request commits and make the use of
the nightly runner pool for main.yml jobs explicit.
Result:
Improved test coverage.
Enable macOS CI on merge to main and daily timer
### Motivation:
* Improve test coverage
* Check test pass/fail status
* Monitor CI throughput
### Modifications:
Enable macOS CI to be run on all merges to main and on a daily timer.
### Result:
Improved test coverage run out-of-band at the moment so we can get a
feeling for if any changes need to be made in the repo or in the CI
pipelines to ensure timely and stable checks.
### Motivation:
We now have centrally-hosted CMake checks in the NIO repository which we
should use to reduce maintenance. The new checks also increase coverage
by performing a build with CMake as part of the checks.
### Modifications:
* Use the new workflow
* Commit formatting changes in the CMakeLists files from the new script
* Document how to update the CMakeLists files
* Remove the obsolete scripts
### Result:
Better CI coverage.
### Motivation
Currently this package doesn't build for the non-macOS Apple platforms.
For example, compiling for iOS fails with:
- `error: 'some' return types are only available in iOS 13.0.0 or newer`
- `error: Concurrency is only available in iOS 13.0.0 or newer`
Looks like a few types were missing the availability annotations when
this package switched to using them and dropping the minimum platform
requirement.
### Modifications
- Add missing annotations to restore build.
### Results
- Package now builds on iOS, tvOS, and watchOS.
- `struct NameConstraints`, `struct NameConstraintsValue` are marked
only available on iOS 13+ etc.
- `protocol OCSPRequester` is marked only available on iOS 13+ etc.
Minimum deployment versions in package manifests can be problematic for
libraries, because changing them or adding them to an existing package
that doesn't already use them forces SemVer breaking majors.
Furthermore, depending on a new library that specifies minimum
deployment targets would force the adopting library to also have to add
these platforms to its manifest (which would in turn force a major).
This PR removes the platforms stanza from the package manifest and
replaces it with availability guards where necessary.
`swift-certificates` needed the platforms stanza because `swift-crypto`
forced it onto its adopters. After
https://github.com/apple/swift-crypto/pull/331, this isn't needed
anymore.
When the value is not a printable or UTF8 string, it may be useful to be
able to access the underlying encoded bytes.
Co-authored-by: David Nadoba <d_nadoba@apple.com>
Most of the time, the signature algorithm that should be used is
dictated by the type of the private key.
* Ed25519 keys support only one signature algorithm.
* RFC 5753 section 8 recommends that "[the P-256 curve] be used with
SHA-256; the P-384 curve be used with SHA-384; and the P-521 curve be
used with SHA-512".
* RSA keys support 4 signature algorithms. But most people use RSA with
SHA-256 and nobody should use RSA with SHA-1 anymore.
More over, Certificate.PrivateKey is opaque to the user, who may not
know what type of private key they're using and what the appropriate
signature algorithm is.
For those reasons, we add convenience wrappers around methods with a
signature algorithm to provide a reasonable default value.
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>
Fix when "${CMAKE_SYSTEM_PROCESSOR}" is lowercase "amd64"
---------
Co-authored-by: David Nadoba <d_nadoba@apple.com>
Co-authored-by: David Nadoba <dnadoba@gmail.com>
Per [RFC 5652 §
11.2](https://datatracker.ietf.org/doc/html/rfc5652#section-11.2):
"For signed-data, the message digest is computed using the signer's
message digest algorithm."
Currently, when computing the signed attributes' message digest,
`CMS.sign` assumes the digest algorithm is SHA256, which is incorrect.
The behavior of `CMS.isValid` is already correct and doesn't need
updating. I've made `Digest` conform to `Sequence` to facilitate the
conversion/comparison of the message digest.
---------
Co-authored-by: Cory Benfield <lukasa@apple.com>
Some certificate authorities issue certificates with invalid RDN
attribute values. Certificates must use UTF8String instead of
PrintableString to represent strings that contains `*` or `@`, but
mistakes happen.
When a RDN attribute value is a PrintableString or UTF8String with an
invalid content, rather than rejecting the certificate, fall back to
storing the value as an Any.
## Rationale
Certificate authorities using the wrong string type is a common mistake.
For example, DigiCert issued intermediate certificates with invalid
ampersands to Wells Fargo & Company (golang/go#22970).
This PR adds *partial* support for certificates that contain invalid
PrintableString or UTF8String (less likely) values. When failing to
parse a PrintableString or UTF8String, the raw bytes are stored as an
Any (same as IA5String, BMPString, ...).
Though those certificates are now parsed without any error, they aren't
fully supported yet. Trying to convert the value to a String returns
`nil`, so the CN doesn't match. I don't know whether we should add
support for converting invalid PrintableString values (and
IA5String/BMPString/...) to String in the future. In the meantime,
developers who want to read the CN have access the raw Any value.
Motivation:
To catch potential data races at build time.
Modifications:
- Bump Swift tools version from 5.8 to 5.9 in Package.swift.
- Enable strict concurrency in Package.swift.
- Adjust the documentation section on the supported Swift versions.
- Implement minor fixes for the surfaced strict concurrency warnings.
- Add `-require-explicit-sendable` to the 6.0, nightly 6.0 and nightly
main CI checks.
Result:
Strict concurrency adoption.
Motivation:
The test fails when the local machine is not set to 24-hour time.
Modifications:
- Adjust the test to use dynamic time values based on Foundation's
`Date` instead of hard-coded time strings.
Result:
A non-flaky test.
Co-authored-by: Cory Benfield <lukasa@apple.com>
Enable MemberImportVisibility check on all targets. Use a standard
string header and footer to bracket the new block for ease of updating
in the future with scripts.
* Add support for attached signatures (#201)
* Relay detachment through with signing time
* Factor attachment into generateSignedData
* Adjust test coverage
* Test verifying an attached signature
* Test verifying an attached signature and timestamp
* Test failing detached signature as attached
* Test failing detached timed signature as attached
* Test accepting attached signature as detached
* Test accepting attached timed signature as detached
Motivation
While Ed25519 is not available in the WebPKI, there
are a number of contexts where it's an appropriate
signature algorithm for X.509. In those contexts,
we should allow the signature algorithm.
Modifications
Add support for Ed25519 keys and signatures.
Add unit tests
Result
Ed25519 support in the X509 certs
Motivation:
I would like to create Certificates using a SecKey so that I can create certificates signed by hardware-backed keys. Currently, Swift Certificates requires the private key be provided in an exported representation, but this isn't possible when a SecKey is marked as non-exportable.
Modifications:
Adds a new SecKeyWrapper backing to Certificate.PrivateKey to support initalisation with SecKey. This wrapper struct handles key validation and signing operations by calling the appropriate SecKey interfaces. Adds additional tests to support new backing type.
Result:
Certifcate.PrivateKey can be initialised with a SecKey, allowing existing hardware-backed SecKey instances to be used as the issuer private key for new Certificate instances.
Co-authored-by: Rory Smith <rory.s@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
Motivation:
Crypto does not yet support concurrency.
Modifications:
Change Crypto imports where necessary to import
with preconcurrency flag.
Result:
Fewer warnings in swift 6.
Motivation:
This is consistent with what underlying assert does.
Swift 6 warns about this mismatch
Modifications:
Use filePath for test assert location
Result:
Consistency in test assert location reportin
DistinguishedName was incorrectly marked DERImplicitlyTaggable,
but it isn't. DistinguishedName is our name for Name, which is
an untagged choice type. Untagged choice types can never be
implicitly tagged.