fix(elbv2): hold a listener's default certificate apart from its list (#8240)

A listener kept one certificate list with its default at the head, which left
four readings of the reference unanswered. DescribeListenerCertificates names
"the default certificate and the certificate list", telling them apart by
IsDefault and naming a default the list holds as well twice, "once with
IsDefault set to true and once with IsDefault set to false", where Floci
answered one flat list and no IsDefault at all. A listener's own Certificates
member is "the default certificate for the listener", and IsDefault "is not
included in the output when describing a listener", where Floci named every
certificate the listener held there. ModifyListener replaces the default alone,
the Application Load Balancers guide saying of a default added to the
certificate list that it "is used with the SNI protocol even if it is replaced
as the default certificate", where Floci dropped the list with the replacement.
And a listener made through the API starts with an empty certificate list,
which the same guide says of every listener not made in the console.

The default and the list are two members of the listener now, with the served
set, the default first and the list behind it, derived for the data plane and
for the certificate references. A listener saved before this reads the head of
its one list as the default and the rest as its certificate list.

The member create and modify take is held to one certificate, the reference
saying of it on both operations "You must provide exactly one certificate." No
published sentence gives the code a longer list is answered with, so it is the
ValidationError this service answers a request shape with, which is Floci's
reading rather than a sentence of AWS's.

AddListenerCertificates is left taking a list. Its member reads "You can
specify one certificate per call", while the Application Load Balancers guide
adds three certificates in one call of its own, so the sentence and the example
disagree and the example is the behaviour to keep. The operation answers with
the certificate list the add leaves behind now, which is what its output member
describes, rather than with the certificates the call named.

TooManyCertificates is answered for the first time. The published quota is
"Certificates per Application Load Balancer (excluding default certificates):
25", the number DescribeAccountLimits has been reporting all along, so the
listeners of one load balancer share that ceiling, their default certificates
are left out of the count, and the add that would pass it is refused. The
ceiling is the load balancer's rather than the listener's, so it is counted
where the write is made, under the lock a listener's certificate write takes:
two adds on sibling listeners would otherwise each count the other's list as it
stood before the other wrote and pass it together. Create reaches no quota, a
default certificate not being counted, and modify reaches it through its
default alone, a default the certificate list holds as well not being counted
while it is the default, so replacing it starts counting that entry. The number
in hand is the Application Load Balancer one, and a TLS listener on a Network
Load Balancer is held to the same ceiling, which is Floci's reading rather than
a published number of its own.

Removing a default certificate the certificate list holds as well stays
refused: "You can't remove the default certificate for a listener" names no
exception for that case.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-13 22:40:59 -04:00
1 parent 58930c9278
commit ea4427ca58
12 files changed
+666 -84

No files matched your search

@@ -822,10 +822,11 @@ public class ElbV2DataPlane {
Set<String> hosts = new LinkedHashSet<>();
List<CertificateMaterial> certificates = new ArrayList<>();
if (secure) {
if (listener.getCertificates() == null || listener.getCertificates().isEmpty()) {
List<String> served = listener.servedCertificates();
if (served.isEmpty()) {
throw new IllegalStateException("HTTPS listener has no default certificate");
}
for (String certificateArn : listener.getCertificates()) {
for (String certificateArn : served) {
CertificateMaterial certificate = certificateResolver.publishedMaterial(
listener.getListenerArn(), region, certificateArn);
try {
@@ -47,7 +47,8 @@ public class ElbV2QueryHandler {
ACCOUNT_LIMITS.put("rules-per-application-load-balancer", "100");
ACCOUNT_LIMITS.put("target-groups-per-application-load-balancer", "100");
ACCOUNT_LIMITS.put("targets-per-application-load-balancer", "1000");
ACCOUNT_LIMITS.put("certificates-per-application-load-balancer", "25");
ACCOUNT_LIMITS.put("certificates-per-application-load-balancer",
String.valueOf(ElbV2Service.CERTIFICATES_PER_LOAD_BALANCER));
ACCOUNT_LIMITS.put("condition-values-per-alb-rule", "5");
ACCOUNT_LIMITS.put("condition-wildcards-per-alb-rule", "5");
}
@@ -775,13 +776,13 @@ public class ElbV2QueryHandler {
private Response handleAddListenerCertificates(MultivaluedMap<String, String> p, String region) {
String listenerArn = p.getFirst("ListenerArn");
List<String> certs = parseCertificateList(p, "Certificates");
service.addListenerCertificates(region, listenerArn, certs);
List<String> certificateList = service.addListenerCertificates(region, listenerArn, certs);
XmlBuilder xml = new XmlBuilder()
.start("AddListenerCertificatesResponse", AwsNamespaces.ELB_V2)
.start("AddListenerCertificatesResult")
.start("Certificates");
for (String c : certs) {
for (String c : certificateList) {
xml.start("member").elem("CertificateArn", c).end("member");
}
xml.end("Certificates")
@@ -800,12 +801,22 @@ public class ElbV2QueryHandler {
private Response handleDescribeListenerCertificates(MultivaluedMap<String, String> p, String region) {
String listenerArn = p.getFirst("ListenerArn");
List<String> certs = service.describeListenerCertificates(region, listenerArn);
List<ElbV2Service.ListenerCertificate> certs =
service.describeListenerCertificates(region, listenerArn);
XmlBuilder xml = new XmlBuilder()
.start("DescribeListenerCertificatesResponse", AwsNamespaces.ELB_V2)
.start("DescribeListenerCertificatesResult");
appendCertificates(xml, certs);
if (!certs.isEmpty()) {
xml.start("Certificates");
for (ElbV2Service.ListenerCertificate certificate : certs) {
xml.start("member")
.elem("CertificateArn", certificate.certificateArn())
.elem("IsDefault", String.valueOf(certificate.isDefault()))
.end("member");
}
xml.end("Certificates");
}
xml.end("DescribeListenerCertificatesResult")
.raw(AwsQueryResponse.responseMetadata())
.end("DescribeListenerCertificatesResponse");
@@ -878,7 +889,8 @@ public class ElbV2QueryHandler {
if (l.getPort() != null) xml.elem("Port", String.valueOf(l.getPort()));
xml.elem("Protocol", safe(l.getProtocol()));
xml.elem("SslPolicy", l.getSslPolicy());
appendCertificates(xml, l.getCertificates());
appendCertificates(xml, l.getDefaultCertificate() == null ? List.of()
: List.of(l.getDefaultCertificate()));
xml.start("DefaultActions");
for (Action a : l.getDefaultActions()) {
xml.start("member").raw(actionXml(a)).end("member");
@@ -892,6 +904,7 @@ public class ElbV2QueryHandler {
return xml.build();
}
/** The {@code Certificates} a listener carries, which is its default certificate alone. */
private static void appendCertificates(XmlBuilder xml, List<String> certificates) {
if (!certificates.isEmpty()) {
xml.start("Certificates");
@@ -48,6 +48,12 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
private static final Logger LOG = Logger.getLogger(ElbV2Service.class);
private static final String DEFAULT_SSL_POLICY = "ELBSecurityPolicy-2016-08";
/**
* "Certificates per Application Load Balancer (excluding default certificates)", the one
* certificate quota the reference publishes a number for, and the number
* {@code DescribeAccountLimits} reports.
*/
public static final int CERTIFICATES_PER_LOAD_BALANCER = 25;
/** {@code LoadBalancerTypeEnum}, in the model's order. */
private static final List<String> LOAD_BALANCER_TYPES = List.of("application", "network", "gateway");
@@ -670,6 +676,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
List<Action> defaultActions, List<String> alpnPolicy,
Map<String, String> initialTags) {
validatePort(port, "port");
requireOneDefaultCertificate(certificates);
requireGatewayListenerSettings(requireLoadBalancer(region, lbArn), protocol, port);
Map<String, Listener> regionListeners = listeners.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
@@ -701,7 +708,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
listener.setProtocol(protocol != null ? protocol : ("gateway".equals(lbType) ? "GENEVE" : "HTTP"));
listener.setSslPolicy(sslPolicy == null && servesCertificates(listener.getProtocol())
? DEFAULT_SSL_POLICY : sslPolicy);
listener.setCertificates(certificates != null ? new ArrayList<>(certificates) : new ArrayList<>());
listener.setDefaultCertificate(defaultCertificateOf(certificates));
listener.setDefaultActions(defaultActions != null ? new ArrayList<>(defaultActions) : new ArrayList<>());
listener.setAlpnPolicy(alpnPolicy != null ? new ArrayList<>(alpnPolicy) : new ArrayList<>());
@@ -838,6 +845,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
String sslPolicy, List<String> certificates,
List<Action> defaultActions, List<String> alpnPolicy) {
validatePort(port, "port");
requireOneDefaultCertificate(certificates);
while (true) {
Listener initial = requireListener(region, listenerArn);
LoadBalancer initialLb = requireLoadBalancer(region, initial.getLoadBalancerArn());
@@ -857,13 +865,14 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
Listener listener = requireListener(region, listenerArn);
LoadBalancer lb = requireLoadBalancer(region, listener.getLoadBalancerArn());
ListenerState expected = listenerState(listener, lb);
Listener prospective = prospectiveListener(expected, protocol, port, certificates);
Listener prospective = prospectiveListener(expected, protocol, port,
defaultCertificateOf(certificates), null);
boolean clearSecuritySettings = clearsSecuritySettings(expected.protocol(), protocol);
requireAvailableListenerPort(listeners.getOrDefault(region, Map.of()), listener.getLoadBalancerArn(),
listenerArn, prospective.getPort());
if (!validateExistingListener(region, expected, lb, () -> {
requireListenerProtocolTransition(expected.protocol(), protocol, sslPolicy, certificates);
requireListenerCertificates(region, prospective.getProtocol(), prospective.getCertificates());
requireListenerCertificates(region, prospective.getProtocol(), prospective.servedCertificates());
requireCompatibleListenerProtocol(listenerArn, prospective.getPort(), prospective.getProtocol());
})) {
continue;
@@ -888,7 +897,13 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
listener.setSslPolicy(sslPolicy);
}
if (certificates != null || clearSecuritySettings) {
listener.setCertificates(new ArrayList<>(prospective.getCertificates()));
// A default the certificate list holds as well is not counted while it is
// the default, so replacing it starts counting it and the ceiling has to be
// asked about, which is why this operation models TooManyCertificates too.
requireCertificateQuota(region, expected, prospective.getDefaultCertificate(),
prospective.getCertificateList());
listener.setDefaultCertificate(prospective.getDefaultCertificate());
listener.setCertificateList(new ArrayList<>(prospective.getCertificateList()));
}
if (alpnPolicy != null) {
listener.setAlpnPolicy(new ArrayList<>(alpnPolicy));
@@ -913,15 +928,15 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
boolean applied = restart
? publishExistingListener(prospective, region, expected, lb,
() -> requireCertificates(region, prospective.getProtocol(),
certificates != null ? certificates : prospective.getCertificates()), publication)
: supplyCertificatesHeld(prospective.getCertificates(), () -> {
certificates != null ? certificates : prospective.servedCertificates()), publication)
: supplyCertificatesHeld(prospective.servedCertificates(), () -> {
synchronized (lb) {
if (!isCurrentListener(region, expected)) {
return false;
}
}
requireCertificates(region, prospective.getProtocol(), prospective.getCertificates());
requirePublishedCertificates(region, prospective.getProtocol(), prospective.getCertificates());
requireCertificates(region, prospective.getProtocol(), prospective.servedCertificates());
requirePublishedCertificates(region, prospective.getProtocol(), prospective.servedCertificates());
return dataPlane.updateListener(expected.port(), publication);
});
if (applied) {
@@ -1210,7 +1225,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
List<Reference> references = new ArrayList<>();
for (Map<String, Listener> regionListeners : listeners.values()) {
for (Listener listener : regionListeners.values()) {
for (String certificate : listener.getCertificates()) {
for (String certificate : listener.servedCertificates()) {
references.add(new Reference(certificate, "listener " + listener.getListenerArn()));
}
}
@@ -1218,25 +1233,34 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
return references;
}
public void addListenerCertificates(String region, String listenerArn, List<String> certArns) {
/**
* The certificate list as the add leaves it, which is what the operation answers with: "the
* certificates in the certificate list", rather than the certificates the call named.
*
* <p>The reference's member says one certificate per call, and the Application Load Balancers
* guide adds three in one call of its own, so a list is taken.
*/
public List<String> addListenerCertificates(String region, String listenerArn, List<String> certArns) {
Listener initial = requireListener(region, listenerArn);
requireCertificates(region, initial.getProtocol(), certArns);
changeListenerCertificates(region, listenerArn, certArns, false);
return changeListenerCertificates(region, listenerArn, certArns, false);
}
public void removeListenerCertificates(String region, String listenerArn, List<String> certArns) {
changeListenerCertificates(region, listenerArn, certArns, true);
}
private void changeListenerCertificates(String region, String listenerArn, List<String> requested, boolean remove) {
private List<String> changeListenerCertificates(String region, String listenerArn,
List<String> requested, boolean remove) {
while (true) {
Listener listener = requireListener(region, listenerArn);
LoadBalancer lb = requireLoadBalancer(region, listener.getLoadBalancerArn());
ListenerState expected = listenerState(listener, lb);
List<String> certificates = new ArrayList<>(expected.certificates());
List<String> certificates = new ArrayList<>(expected.certificateList());
boolean namesTheDefault = remove && expected.defaultCertificate() != null
&& requested.contains(expected.defaultCertificate());
if (remove) {
if (servesCertificates(expected.protocol()) && !certificates.isEmpty()
&& requested.contains(certificates.getFirst())) {
if (servesCertificates(expected.protocol()) && namesTheDefault) {
throw new AwsException("OperationNotPermitted",
"The default listener certificate cannot be removed.", 400);
}
@@ -1251,11 +1275,16 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
certificates.add(arn);
}
}
requireCertificateQuota(region, expected, certificates);
}
Listener prospective = prospectiveListener(expected, null, null, null, certificates);
if (namesTheDefault) {
prospective.setDefaultCertificate(null);
}
Listener prospective = prospectiveListener(expected, null, null, certificates);
if (publishExistingListener(prospective, region, expected, lb, () -> {
if (!remove) {
requireCertificates(region, expected.protocol(), requested);
requireCertificateQuota(region, expected, certificates);
}
}, () -> {
synchronized (lb) {
@@ -1263,28 +1292,109 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
if (!isCurrentListener(region, expected)) {
return false;
}
listener.setCertificates(certificates);
if (!remove) {
// The ceiling belongs to the load balancer rather than to the listener, so
// it is counted here as well, under the lock every certificate write takes:
// two adds on sibling listeners would otherwise each count the other's list
// as it was before the other wrote and pass the ceiling together.
requireCertificateQuota(region, expected, certificates);
}
listener.setCertificateList(certificates);
if (namesTheDefault) {
// Only a listener of a protocol the member does not describe reaches here,
// the throw above refusing the removal otherwise, and it keeps the
// behaviour this service had before the default was held apart.
listener.setDefaultCertificate(null);
}
persistRegion(listeners, region);
return true;
}
})) {
return;
return certificates;
}
}
}
public List<String> describeListenerCertificates(String region, String listenerArn) {
/**
* The quota the reference publishes is per load balancer and excludes the default certificates,
* so a listener's own default is not counted where its certificate list holds it as well, and
* the listeners of one load balancer share the ceiling. The default the count is taken against
* is the one the write leaves behind rather than the one the listener holds now, since
* replacing a default the certificate list also holds starts counting it. The number in hand is
* the Application Load Balancer one; a TLS listener on a Network Load Balancer is held to the
* same ceiling, which is Floci's reading rather than a sentence of its own.
*/
private void requireCertificateQuota(String region, ListenerState expected, List<String> certificateList) {
requireCertificateQuota(region, expected, expected.defaultCertificate(), certificateList);
}
private void requireCertificateQuota(String region, ListenerState expected, String defaultCertificate,
List<String> certificateList) {
String loadBalancerArn = expected.listener().getLoadBalancerArn();
String listenerArn = expected.listener().getListenerArn();
int held = countedCertificates(defaultCertificate, certificateList);
for (Listener other : listeners.getOrDefault(region, Map.of()).values()) {
if (loadBalancerArn.equals(other.getLoadBalancerArn())
&& !listenerArn.equals(other.getListenerArn())) {
held += countedCertificates(other.getDefaultCertificate(), other.getCertificateList());
}
}
if (held > CERTIFICATES_PER_LOAD_BALANCER) {
throw new AwsException("TooManyCertificates",
"You've reached the limit on the number of certificates per load balancer.", 400);
}
}
private static int countedCertificates(String defaultCertificate, List<String> certificateList) {
return (int) certificateList.stream().filter(arn -> !arn.equals(defaultCertificate)).count();
}
/**
* The default certificate and then the certificate list, a default the list holds as well
* named twice, "once with IsDefault set to true and once with IsDefault set to false".
*/
public List<ListenerCertificate> describeListenerCertificates(String region, String listenerArn) {
Listener listener = requireListener(region, listenerArn);
return new ArrayList<>(listener.getCertificates());
List<ListenerCertificate> certificates = new ArrayList<>();
if (listener.getDefaultCertificate() != null) {
certificates.add(new ListenerCertificate(listener.getDefaultCertificate(), true));
}
for (String certificate : listener.getCertificateList()) {
certificates.add(new ListenerCertificate(certificate, false));
}
return certificates;
}
/** A certificate {@code DescribeListenerCertificates} names, and the part it plays. */
public record ListenerCertificate(String certificateArn, boolean isDefault) {}
/**
* The member both create and modify read as the listener's default certificate, where the
* reference says "You must provide exactly one certificate." No source gives the code a longer
* list is answered with, so it is the {@code ValidationError} this service answers a request
* shape with, which is Floci's reading.
*/
private static void requireOneDefaultCertificate(List<String> certificates) {
if (certificates != null && certificates.size() > 1) {
throw new AwsException("ValidationError",
"You must provide exactly one certificate.", 400);
}
}
private static String defaultCertificateOf(List<String> certificates) {
return certificates == null || certificates.isEmpty() ? null : certificates.getFirst();
}
// ── Helpers ───────────────────────────────────────────────────────────────
private record ListenerState(Listener listener, Integer port, String protocol, List<String> certificates) {}
private record ListenerState(Listener listener, Integer port, String protocol,
String defaultCertificate, List<String> certificateList,
List<String> certificates) {}
private static ListenerState listenerState(Listener listener) {
return new ListenerState(listener, listener.getPort(), listener.getProtocol(),
new ArrayList<>(listener.getCertificates()));
listener.getDefaultCertificate(), new ArrayList<>(listener.getCertificateList()),
listener.servedCertificates());
}
private static ListenerState listenerState(Listener listener, LoadBalancer lb) {
@@ -1297,18 +1407,23 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
Listener current = listeners.getOrDefault(region, Map.of()).get(expected.listener().getListenerArn());
return current == expected.listener() && Objects.equals(current.getPort(), expected.port())
&& Objects.equals(current.getProtocol(), expected.protocol())
&& current.getCertificates().equals(expected.certificates());
&& Objects.equals(current.getDefaultCertificate(), expected.defaultCertificate())
&& current.getCertificateList().equals(expected.certificateList());
}
private static Listener prospectiveListener(ListenerState expected, String protocol, Integer port,
List<String> certificates) {
String defaultCertificate, List<String> certificateList) {
Listener prospective = new Listener();
prospective.setListenerArn(expected.listener().getListenerArn());
prospective.setLoadBalancerArn(expected.listener().getLoadBalancerArn());
prospective.setPort(port != null ? port : expected.port());
prospective.setProtocol(protocol != null ? protocol : expected.protocol());
prospective.setCertificates(clearsSecuritySettings(expected.protocol(), protocol) ? new ArrayList<>()
: new ArrayList<>(certificates != null ? certificates : expected.certificates()));
if (!clearsSecuritySettings(expected.protocol(), protocol)) {
prospective.setDefaultCertificate(defaultCertificate != null ? defaultCertificate
: expected.defaultCertificate());
prospective.setCertificateList(new ArrayList<>(certificateList != null ? certificateList
: expected.certificateList()));
}
return prospective;
}
@@ -1416,7 +1531,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
LoadBalancer lb, Runnable referenceValidation, BooleanSupplier publication) {
try {
return publishListener(prospective, region, expected.port(), publication,
operation -> supplyCertificatesHeld(prospective.getCertificates(), () -> {
operation -> supplyCertificatesHeld(prospective.servedCertificates(), () -> {
synchronized (lb) {
if (!isCurrentListener(region, expected)
|| loadBalancers.getOrDefault(region, Map.of()).get(lb.getLoadBalancerArn()) != lb) {
@@ -1424,7 +1539,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
}
}
referenceValidation.run();
requirePublishedCertificates(region, prospective.getProtocol(), prospective.getCertificates());
requirePublishedCertificates(region, prospective.getProtocol(), prospective.servedCertificates());
return operation.get();
}));
} catch (AwsException failure) {
@@ -1446,7 +1561,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
return;
}
ListenerState expected = listenerState(listener, lb);
if (publishExistingListener(prospectiveListener(expected, null, null, null), region, expected, lb,
if (publishExistingListener(prospectiveListener(expected, null, null, null, null), region, expected, lb,
() -> { }, () -> {
synchronized (lb) {
return loadBalancers.getOrDefault(region, Map.of()).get(lb.getLoadBalancerArn()) == lb
@@ -1527,7 +1642,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
List<CertificateReference> references = new ArrayList<>();
for (Map<String, Listener> regionListeners : listeners.values()) {
for (Listener listener : regionListeners.values()) {
for (String certificateArn : listener.getCertificates()) {
for (String certificateArn : listener.servedCertificates()) {
references.add(new CertificateReference(certificateArn, listener.getLoadBalancerArn()));
}
}
@@ -1537,7 +1652,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
public void certificateReimported(String certificateArn, String region) {
for (Listener listener : listeners.getOrDefault(region, Map.of()).values()) {
if (listener.getCertificates().contains(certificateArn)) {
if (listener.servedCertificates().contains(certificateArn)) {
try {
restoreListener(region, listener.getListenerArn());
} catch (RuntimeException failure) {
@@ -1,6 +1,7 @@
package io.floci.aws.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
@@ -16,7 +17,8 @@ public class Listener {
private String loadBalancerArn;
private Integer port;
private String protocol;
private List<String> certificates = new ArrayList<>();
private String defaultCertificate;
private List<String> certificateList = new ArrayList<>();
private String sslPolicy;
private List<Action> defaultActions = new ArrayList<>();
private List<String> alpnPolicy = new ArrayList<>();
@@ -36,8 +38,44 @@ public class Listener {
public String getProtocol() { return protocol; }
public void setProtocol(String protocol) { this.protocol = protocol; }
public List<String> getCertificates() { return certificates; }
public void setCertificates(List<String> certificates) { this.certificates = certificates; }
public String getDefaultCertificate() { return defaultCertificate; }
public void setDefaultCertificate(String defaultCertificate) { this.defaultCertificate = defaultCertificate; }
public List<String> getCertificateList() { return certificateList; }
public void setCertificateList(List<String> certificateList) { this.certificateList = certificateList; }
/**
* The certificates the listener serves, its default first and then its certificate list, a
* certificate both of them name appearing once. The two are kept apart because the reference
* keeps them apart: the default is what CreateListener and ModifyListener set, one certificate
* at a time, the list is what AddListenerCertificates adds to, and DescribeListenerCertificates
* names a default the list holds as well twice, telling the two apart by IsDefault.
*/
public List<String> servedCertificates() {
List<String> served = new ArrayList<>();
if (defaultCertificate != null) {
served.add(defaultCertificate);
}
for (String certificate : certificateList) {
if (!served.contains(certificate)) {
served.add(certificate);
}
}
return served;
}
/**
* Reads a listener saved before the default certificate and the certificate list were kept
* apart, when both sat in one list with the default at its head. Nothing writes this member.
*/
@JsonProperty("certificates")
void setSavedCertificates(List<String> certificates) {
if (certificates == null || certificates.isEmpty()) {
return;
}
this.defaultCertificate = certificates.getFirst();
this.certificateList = new ArrayList<>(certificates.subList(1, certificates.size()));
}
public String getSslPolicy() { return sslPolicy; }
public void setSslPolicy(String sslPolicy) { this.sslPolicy = sslPolicy; }