mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(iot): real device certificates issued by the local CA (#3079)
* feat(iot): CreateKeysAndCertificate issues a real client certificate from the local CA certificateId is sha256(DER) in lowercase hex as on AWS; the returned RSA 2048 key pair matches the certificate. CreateCertificateFromCsr parses the PKCS#10, checks its self-signature and key strength (RSA 2048 or more, EC P-256/384/521), signs the CSR's key with the same CA and returns no private key, as on AWS. * docs(iot): describe the CA-issued device certificates * fix(iot): accept only the NIST curves AWS IoT names and never store a device private key The CSR key check reads the named-curve identifier instead of the field size, so secp256k1 and explicit curve parameters are refused as on AWS. The stored certificate record no longer carries the private key; it is returned once. * feat(iot): device certificates expire at the end of 2049 and DescribeCertificate reports validity AWS IoT-issued client certificates all carry notAfter 2049-12-31T23:59:59Z. CertificateGenerator gains an overload with an explicit validity window; DescribeCertificate adds validity.notBefore, validity.notAfter and certificateMode DEFAULT. The Java SDK compatibility test asserts the shape. * fix(iot): a device certificate never outlives its issuing CA A new local CA is valid until the end of 2050, past AWS's fixed 2049 device expiry; a CA created earlier (ten years) caps the device certificates it signs at its own expiry, so a chain never expires before its leaf. * fix(iot): derive CA and device expiry from creation time, never mint an expired certificate A CA created after 2050 lives ten years from creation instead of ending on the fixed date; after 2049 a device certificate lives a year, still capped at its CA. The Python compatibility suite now sends a real PKCS#10 request, since the placeholder it used is refused as on AWS. * docs(tls): the local CA now signs IoT device certificates * test(iot): pass the certificate authority to IotServiceTest's constructor
This commit is contained in:
1 parent
bf517ac952
commit
c67e598594
13 files changed
+711
-35
No files matched your search
@@ -10,6 +10,7 @@ import software.amazon.awssdk.services.iot.model.AttributePayload;
|
||||
import software.amazon.awssdk.services.iot.model.AttachPolicyRequest;
|
||||
import software.amazon.awssdk.services.iot.model.AttachThingPrincipalRequest;
|
||||
import software.amazon.awssdk.services.iot.model.AuthorizerConfig;
|
||||
import software.amazon.awssdk.services.iot.model.CertificateMode;
|
||||
import software.amazon.awssdk.services.iot.model.CertificateStatus;
|
||||
import software.amazon.awssdk.services.iot.model.Action;
|
||||
import software.amazon.awssdk.services.iot.model.AddThingToThingGroupRequest;
|
||||
@@ -363,6 +364,11 @@ class IotTest {
|
||||
.certificateId(cert.certificateId())
|
||||
.build());
|
||||
assertThat(described.certificateDescription().status()).isEqualTo(CertificateStatus.ACTIVE);
|
||||
assertThat(described.certificateDescription().certificateMode()).isEqualTo(CertificateMode.DEFAULT);
|
||||
assertThat(described.certificateDescription().validity().notAfter())
|
||||
.isEqualTo(java.time.Instant.parse("2049-12-31T23:59:59Z"));
|
||||
assertThat(cert.certificateId()).matches("[0-9a-f]{64}");
|
||||
assertThat(cert.keyPair().privateKey()).startsWith("-----BEGIN RSA PRIVATE KEY-----");
|
||||
|
||||
var certs = iot.listCertificates(ListCertificatesRequest.builder().build());
|
||||
assertThat(certs.certificates()).anyMatch(item -> cert.certificateArn().equals(item.certificateArn()));
|
||||
|
||||
Reference in new issue
Block a user