@@ -113,6 +113,7 @@ public final class CertificateBuilder { |
113 | 113 | static final String OID_PKIX_KP_EMAIL_PROTECTION = OID_PKIX_KP + ".4"; |
114 | 114 | static final String OID_PKIX_KP_TIME_STAMPING = OID_PKIX_KP + ".8"; |
115 | 115 | static final String OID_PKIX_KP_OCSP_SIGNING = OID_PKIX_KP + ".9"; |
| 116 | + static final String OID_PKIX_PE_ACME_IDENTIFIER = "1.3.6.1.5.5.7.1.31"; |
116 | 117 | static final String OID_KERBEROS_KEY_PURPOSE_CLIENT_AUTH = "1.3.6.1.5.2.3.4"; |
117 | 118 | static final String OID_MICROSOFT_SMARTCARD_LOGIN = "1.3.6.1.4.1.311.20.2.2"; |
118 | 119 | private static final GeneralName[] EMPTY_GENERAL_NAMES = new GeneralName[0]; |
@@ -560,6 +561,31 @@ public CertificateBuilder addExtensionAsciiString(String identifierOID, boolean |
560 | 561 | } |
561 | 562 | } |
562 | 563 |
|
| 564 | + /** |
| 565 | + * Add an {@code acmeIdentifier} extension marked {@code critical}, with the given authorization SHA-256 value. |
| 566 | + * <p> |
| 567 | + * The {@code acmeIdentifier} extension is specified by |
| 568 | + * <a href="https://datatracker.ietf.org/doc/html/rfc8737">RFC 8737</a>, |
| 569 | + * which specify the TLS-ALPN-01 challenge type. |
| 570 | + * See the <a href="https://letsencrypt.org/docs/challenge-types/#tls-alpn-01">Let's Encrypt documentation</a> |
| 571 | + * for a short summary of this ACME challenge method. |
| 572 | + * <p> |
| 573 | + * To use this challenge method, the server must accept TLS connections with an ALPN protocol name of |
| 574 | + * {@code acme-tls/1} and an SNI extension for the hostname being challenged. |
| 575 | + * The server must then offer a self-signed certificate that include both this extension, |
| 576 | + * and a {@linkplain #addSanDnsName(String) dNSName SAN} with the hostname that is being challenged. |
| 577 | + * <p> |
| 578 | + * The extension value must be the SHA-256 of the key authorization challenge. |
| 579 | + * See <a href="https://datatracker.ietf.org/doc/html/rfc8555#section-8.1">RFC 8555</a> for details on key |
| 580 | + * authorizations. |
| 581 | + * |
| 582 | + * @param sha256 The SHA-256 of the key authorization. |
| 583 | + * @return This certificate builder. |
| 584 | + */ |
| 585 | + public CertificateBuilder addAcmeIdentifierExtension(byte[] sha256) { |
| 586 | + return addExtension(OID_PKIX_PE_ACME_IDENTIFIER, true, requireNonNull(sha256, "sha256")); |
| 587 | + } |
| 588 | + |
563 | 589 | /** |
564 | 590 | * The key usage specify the intended usages for which the certificate has been issued. |
565 | 591 | * Some are overlapping, some are deprecated, and some are implied by usage. |
|