284 Commits
Author SHA1 Message Date
Rick Newton-Rogers 86eca75828 add thresholds for Swift 6.1 from 6.0 thresholds (#247) 1.9.0 2025-04-14 16:26:05 +01:00
Rick Newton-Rogers b84149fc0e Enable Swift 6.1 jobs in CI (#246)
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.
2025-04-14 10:47:13 +01:00
Erik Gadireddi bdcbccd1bd Feature: Enhance RDN parsing to support IA5String (#236)
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)
2025-04-10 14:00:00 +00:00
63d06f4504 Make the usual pthread changes for OpenBSD. (#239)
Co-authored-by: David Nadoba <d_nadoba@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-04-09 10:35:15 +00:00
Gus Cairo 9ad2ac038e Add visionOS support (#244) 2025-04-08 13:35:11 +00:00
Gus Cairo 1705c7bce4 Remove warnings as errors from 5.9 main runs (#245)
See https://github.com/apple/swift-certificates/pull/243
2025-04-08 12:56:29 +00:00
Gus Cairo 81563a3f4e Remove warnings as errors from 5.9 CI (#243)
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.
2025-04-08 13:43:40 +01:00
Gus Cairo 4c305e3205 Add macCatalyst to available platforms (#242) 2025-04-08 13:25:54 +01:00
Rick Newton-Rogers 12188b2dc6 Enable macOS CI on pull requests (#240)
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.
2025-04-01 17:40:37 +01:00
Rick Newton-Rogers fc2d54cf0a Enable macOS CI on merge to main and daily timer (#238)
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.
2025-03-26 16:03:00 +00:00
Rick Newton-Rogers 04113b4b6a Use centralized CMake checks (#235)
### 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.
2025-03-17 11:17:06 +00:00
Rick Newton-RogersandCory Benfield 1d394dbc80 Add static SDK CI workflow (#234)
Add static SDK CI workflow which runs on commits to PRs, merges to main
and daily on main.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-03-14 11:22:52 +00:00
Si Beaumont d608282ae5 Add missing availability annotations to fix iOS, watchOS, and tvOS builds (#233)
### 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.
1.8.1
2025-03-13 10:23:22 +00:00
Gus Cairo bd5987524c Replace platforms from Package manifest with availability guards (#232)
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.
1.8.0
2025-03-10 14:31:15 +00:00
Rick Newton-Rogers 6f6e9f8ad9 Only apply standard swift settings on valid targets (#231)
Only apply standard swift settings on valid targets. The current check
ignores plugins but that is not comprehensive enough.
2025-03-07 15:04:57 +00:00
Rick Newton-Rogers db0f068fb7 Delete Thresholds/nightly-6.1 symlink (#230)
Following on from https://github.com/apple/swift-certificates/pull/229
delete `Thresholds/nightly-6.1` which is no longer needed now that the
shared benchmarks workflow has been updated
2025-03-07 12:11:09 +00:00
Rick Newton-Rogers 18d5c3acf8 move nightly-next thresholds and add legacy symlink (#229)
Move nightly-next thresholds and add legacy symlink; see
https://github.com/apple/swift-nio/pull/3122
2025-03-03 15:49:38 +00:00
Rick Newton-Rogers a09d77ed59 Rename nightly_6_1 params to nightly_next (#228)
Rename nightly_6_1 params to nightly_next; see
https://github.com/apple/swift-nio/pull/3122
2025-03-03 14:49:31 +00:00
Gus Cairo a65f903b02 Import FoundationEssentials instead of Foundation when available (#227)
`FoundationEssentials` is more lightweight than `Foundation`, and so we
should switch to importing it when possible.
2025-02-24 14:17:11 +00:00
Nicolas BachschmidtandDavid Nadoba dc098a9193 Make RDN.Attribute.Value conversion to ASN1Any public (#215)
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>
2025-02-19 14:01:07 +00:00
Chris McGee 48abd12804 Add back the _TinyArray.swift to the CMakeLists.txt to fix build errors (#226) 2025-02-18 17:21:05 +00:00
Rick Newton-Rogers 197ba89b06 CI use 6.1 nightlies (#225)
CI use 6.1 nightlies now that Swift development is happening in the 6.1
branch
2025-01-30 09:44:39 +00:00
Nicolas BachschmidtandCory Benfield eaed0355dc Add default value for signature algorithm (#221)
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>
2025-01-27 11:03:56 +00:00
David Nadoba 2c25efadd6 Move nightly-6.0 benchmark thresholds to 6.1 (#224)
6.0 nightly is gone. 6.1 was added somehow. Haven't found a PR for that
though. Not sure how that has changed.
2025-01-25 08:30:52 +00:00
b32a9bae3c fix amd64 support (#223)
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>
2025-01-24 10:09:01 -08:00
Nicolas Bachschmidt 41066b1c60 Fix a small error in AlgorithmIdentifier description and add missing cases (#222)
This PR adds missing cases and fixes a small typo.

I haven't added tests, as `AlgorithmIdentifier` is internal API.
2025-01-20 10:01:21 +00:00
Nicolas BachschmidtandCory Benfield 88ced31d9d Use proper hash when computing message digest in signed attributes (#219)
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>
2025-01-16 16:41:23 +00:00
Nicholas KimandNicholas Kim 821085981b Tag CMS signer identifier implicitly (#218)
As pointed out in
https://github.com/apple/swift-certificates/issues/203, the
SignerIdentifier in PKCS#7 CMS should be implicitly tagged while the
currently swift-certificates explicitly tags it. This PR contains
changes for SignerIdentifier of SubjectKeyIdentifier type to be
implicitly tagged.

[RFC 5652 §
12.1](https://datatracker.ietf.org/doc/html/rfc5652#section-12.1):
```
SignerIdentifier ::= CHOICE {
  issuerAndSerialNumber IssuerAndSerialNumber,
  subjectKeyIdentifier [0] SubjectKeyIdentifier }
  ```
  
  
  Resolves: https://github.com/apple/swift-certificates/issues/203

---------

Co-authored-by: Nicholas Kim <nicholas.kim@kakaobank.com>
2025-01-14 15:02:28 +00:00
Marc Prud'hommeaux 274f8668d3 Add Android import for IPAddressNameTests (#217)
Following on https://github.com/apple/swift-certificates/pull/183 and
https://github.com/apple/swift-certificates/pull/207, we need to `import
Android` in `IPAddressTests.swift` to get `inet_pton` and `in6_addr`.

With this addition, tests pass on Android again.
1.7.0
2025-01-08 10:55:15 +00:00
Franz Busch 608cef1b99 Update release.yml (#216)
Update the release.yml file with the latest label changes
2024-12-18 14:15:35 +01:00
Nicolas Bachschmidt 87d0a2752b Support certificates with invalid RDN attribute values (#214)
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.
2024-12-17 18:25:36 +00:00
Clinton Nkwocha 5fd8063331 Enable strict concurrency (#213)
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.
2024-12-13 18:24:01 +00:00
Clinton NkwochaandCory Benfield d381c58a91 Fix flaky test CertificateTests.testCertificateDescription (#212)
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>
2024-12-11 20:25:49 +00:00
Rick Newton-Rogers 62da4e684d Enable MemberImportVisibility check on all targets (#211)
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.
2024-12-11 14:50:22 +00:00
Franz Busch 14e5b05d67 Aligning semantic version label check name (#210) 2024-11-28 12:54:14 +01:00
Jon C. Thomason d4d564670a Add support for attached signatures (#201) (#206)
* 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
2024-11-22 10:54:27 +00:00
Rick Newton-Rogers 3705c35d9f unify scheduled and main yamls (#208) 2024-11-15 09:47:21 +00:00
Luke Howard 2be7251a3a Android build fixes (#207) 2024-11-08 11:31:34 +00:00
Cory Benfield 27c6b0fcfa Add support for Ed25519 certificates (#205)
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
2024-10-30 13:30:13 +00:00
Franz Busch c0b6a47ffe [CI] Adopt GitHub actions (#193) 2024-10-21 16:01:05 +01:00
Cory Benfield 1fbb6ef21f Avoid the macOS requirement. (#204) 1.6.1 2024-10-15 13:19:03 -07:00
d8799da503 Support SecKey Certificate private keys (#195)
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>
1.6.0
2024-10-02 16:40:39 +01:00
finagolfin a846fc7149 Add support for Android (#183) 2024-09-12 02:35:46 -07:00
Mark SchallandFranz Busch abe0f0b248 Fixing SHA512 in comment (#196)
Co-authored-by: Franz Busch <f.busch@apple.com>
2024-09-11 05:37:44 -07:00
LamTrinh.Dev b1bef483a3 Replace file with filePath for location at OCSPPolicyVerifierTests.swift (#197) 2024-09-10 02:09:37 -07:00
LamTrinh.Dev ae364f8aeb Correct the link of sswg-security at SECURITY.md (#194)
* Correct the link of sswg-security at SECURITY.md

* Correct the link of sswg-security at SECURITY.md.
2024-09-09 02:52:31 -07:00
Franz Busch a7c8875b9f Add release.yml (#191) 2024-09-06 13:10:11 +01:00
Peter Adams 12aefb6230 Import crypto with preconcurrency flag (#187)
Motivation:

Crypto does not yet support concurrency.

Modifications:

Change Crypto imports where necessary to import
with preconcurrency flag.

Result:

Fewer warnings in swift 6.
2024-08-16 01:36:16 -07:00
Peter Adams eb5de35450 Use filePath for test assert location (#185)
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
2024-08-15 12:41:37 -07:00
Cory Benfield 387fb97cf6 Stop implicitly tagging DistinguishedName (#188)
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.
2024-08-15 20:11:51 +01:00