Skip to content
Merged
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
3 changes: 3 additions & 0 deletions checks/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<Match>
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<Match>
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,13 @@ public interface FinalBuildStage {
* supply a binding type or data this builder does not compute itself, such as
* {@code tls-exporter} from a non-JDK TLS stack.
*
* @param serverCertificate the server's end-entity (leaf) TLS certificate to bind to
* @param serverCertificate the server's end-entity (leaf) TLS certificate to bind to,
* or {@code null} to configure no binding
* @return {@code this} builder for use in a chained invocation
* @see #channelBinding(String, byte[])
* @see ChannelBindingPolicy
*/
FinalBuildStage channelBinding(@NotNull X509Certificate serverCertificate);
FinalBuildStage channelBinding(@Nullable X509Certificate serverCertificate);

/**
* Sets the StringPreparation, is recommended to leave the default SASL_PREPARATION.
Expand Down Expand Up @@ -501,14 +502,17 @@ public FinalBuildStage channelBindingPolicy(@NotNull ChannelBindingPolicy policy
}

@Override
public FinalBuildStage channelBinding(@NotNull X509Certificate serverCertificate) {
public FinalBuildStage channelBinding(@Nullable X509Certificate serverCertificate) {
if (serverCertificate == null) {
return this;
}
if (cbindConfigured) {
throw new IllegalStateException(
"channelBinding(X509Certificate) called but channel binding was already configured "
+ "via channelBinding(String, byte[])");
}
cbindConfigured = true;
this.serverCertificate = checkNotNull(serverCertificate, "serverCertificate");
this.serverCertificate = serverCertificate;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ void policyRequire_DualSet_ThrowsException() {
+ "was already configured via channelBinding(String, byte[])", ex2.getMessage());
}

@Test
@DisplayName("Allows null channel binding certificate")
void policyRequire_DualSet_NullCertificate() {
assertDoesNotThrow(
() -> createBaseBuilder(BARE_AND_PLUS)
.channelBinding(null)
.channelBinding(null, null)
.build());
}

@Test
@DisplayName("REQUIRE: Aborts initialization if the server fails to advertise a -PLUS mechanism")
void policyRequire_ServerLacksPlus_ThrowsException() {
Expand Down
Loading