mirror of https://github.com/shred/acme4j
Fix broken output for IP-only CSRs
parent
2f2e59fd36
commit
3c48391123
|
@ -54,7 +54,8 @@ import org.shredzone.acme4j.Identifier;
|
||||||
/**
|
/**
|
||||||
* Generator for a CSR (Certificate Signing Request) suitable for ACME servers.
|
* Generator for a CSR (Certificate Signing Request) suitable for ACME servers.
|
||||||
* <p>
|
* <p>
|
||||||
* Requires {@code Bouncy Castle}. This class is part of the {@code acme4j-utils} module.
|
* Requires {@code Bouncy Castle}. The {@link org.bouncycastle.jce.provider.BouncyCastleProvider}
|
||||||
|
* must also be added as security provider.
|
||||||
*/
|
*/
|
||||||
public class CSRBuilder {
|
public class CSRBuilder {
|
||||||
private static final String SIGNATURE_ALG = "SHA256withRSA";
|
private static final String SIGNATURE_ALG = "SHA256withRSA";
|
||||||
|
@ -256,6 +257,7 @@ public class CSRBuilder {
|
||||||
|
|
||||||
ExtensionsGenerator extensionsGenerator = new ExtensionsGenerator();
|
ExtensionsGenerator extensionsGenerator = new ExtensionsGenerator();
|
||||||
extensionsGenerator.addExtension(Extension.subjectAlternativeName, false, subjectAltName);
|
extensionsGenerator.addExtension(Extension.subjectAlternativeName, false, subjectAltName);
|
||||||
|
|
||||||
p10Builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, extensionsGenerator.generate());
|
p10Builder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, extensionsGenerator.generate());
|
||||||
|
|
||||||
PrivateKey pk = keypair.getPrivate();
|
PrivateKey pk = keypair.getPrivate();
|
||||||
|
@ -319,10 +321,14 @@ public class CSRBuilder {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(namebuilder.build());
|
sb.append(namebuilder.build());
|
||||||
|
if (!namelist.isEmpty()) {
|
||||||
sb.append(namelist.stream().collect(joining(",DNS=", ",DNS=", "")));
|
sb.append(namelist.stream().collect(joining(",DNS=", ",DNS=", "")));
|
||||||
|
}
|
||||||
|
if (!iplist.isEmpty()) {
|
||||||
sb.append(iplist.stream()
|
sb.append(iplist.stream()
|
||||||
.map(InetAddress::getHostAddress)
|
.map(InetAddress::getHostAddress)
|
||||||
.collect(joining(",IP=", ",IP=", "")));
|
.collect(joining(",IP=", ",IP=", "")));
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue