Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
throw new ValidationError('At least one of \'port\' or \'protocol\' is required', scope);
}

if (protocol === ApplicationProtocol.HTTP && props.certificates?.length) {
throw new ValidationError('A certificate cannot be specified for HTTP listeners', scope);
}

validateMutualAuthentication(scope, props.mutualAuthentication);

let advertiseTrustStoreCaNames: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ describe('tests', () => {
});
});

test('HTTP listener requires no certificate', () => {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'Stack');
const lb = new elbv2.ApplicationLoadBalancer(stack, 'LB', { vpc });

// WHEN
const listener = lb.addListener('Listener', {
port: 80,
defaultTargetGroups: [new elbv2.ApplicationTargetGroup(stack, 'Group', { vpc, port: 80 })],
});

// THEN
const errors = listener.node.validate();
expect(errors).toEqual(['A certificate cannot be specified for HTTP listeners']);
});

test('Can configure targetType on TargetGroups', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down
Loading