Skip to content

Commit c0def1a

Browse files
nvidianzchesterxgchenIsaacYangSLA
authored
Fixed a certificate issue with newer OpenSSL (#3775)
### Description Newer OpenSSL (from Ubuntu 25.04) doesn't accept the certs generated by provision. This PR fixed the problem by adding Authority Key ID and Key Usage to the cert extensions. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Quick tests passed locally by running `./runtest.sh`. - [ ] In-line docstrings updated. - [ ] Documentation updated. --------- Co-authored-by: Chester Chen <[email protected]> Co-authored-by: Isaac Yang <[email protected]>
1 parent a278d28 commit c0def1a

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

nvflare/lighter/utils.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,30 @@ def generate_cert(
6161
.serial_number(x509.random_serial_number())
6262
.not_valid_before(datetime.datetime.utcnow())
6363
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=valid_days))
64+
.add_extension(
65+
x509.SubjectKeyIdentifier.from_public_key(subject_pub_key),
66+
critical=False,
67+
)
68+
.add_extension(
69+
x509.AuthorityKeyIdentifier.from_issuer_public_key(signing_pri_key.public_key()),
70+
critical=False,
71+
)
6472
)
73+
6574
if ca:
66-
builder = (
67-
builder.add_extension(
68-
x509.SubjectKeyIdentifier.from_public_key(subject_pub_key),
69-
critical=False,
70-
)
71-
.add_extension(
72-
x509.AuthorityKeyIdentifier.from_issuer_public_key(subject_pub_key),
73-
critical=False,
74-
)
75-
.add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=False)
75+
builder = builder.add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=True).add_extension(
76+
x509.KeyUsage(
77+
digital_signature=True,
78+
content_commitment=True,
79+
key_encipherment=True,
80+
data_encipherment=True,
81+
key_agreement=True,
82+
key_cert_sign=True,
83+
crl_sign=True,
84+
encipher_only=False,
85+
decipher_only=False,
86+
),
87+
critical=False,
7688
)
7789

7890
if server_default_host:

0 commit comments

Comments
 (0)