Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting needClientAuth with TLSParameters #1767

Merged
merged 1 commit into from
Jan 29, 2020
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
6 changes: 4 additions & 2 deletions io/src/main/scala/fs2/io/tls/TLSParameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ sealed trait TLSParameters {
serverNames.foreach(sn => p.setServerNames(sn.asJava))
sniMatchers.foreach(sm => p.setSNIMatchers(sm.asJava))
p.setUseCipherSuitesOrder(useCipherSuitesOrder)
p.setNeedClientAuth(needClientAuth)
p.setWantClientAuth(wantClientAuth)
if (needClientAuth)
p.setNeedClientAuth(needClientAuth)
else if (wantClientAuth)
p.setWantClientAuth(wantClientAuth)
p
}
}
Expand Down
31 changes: 31 additions & 0 deletions io/src/test/scala/fs2/io/tls/TLSParametersSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fs2
package io
package tls

class TLSParametersSpec extends TLSSpec {
"toSSLParameters" - {
"no client auth when wantClientAuth=false and needClientAuth=false" in {
val params = TLSParameters(wantClientAuth = false, needClientAuth = false).toSSLParameters
params.getWantClientAuth shouldBe false
params.getNeedClientAuth shouldBe false
}

"wantClientAuth when wantClientAuth=true and needClientAuth=false" in {
val params = TLSParameters(wantClientAuth = true, needClientAuth = false).toSSLParameters
params.getWantClientAuth shouldBe true
params.getNeedClientAuth shouldBe false
}

"needClientAuth when wantClientAuth=false and needClientAuth=true" in {
val params = TLSParameters(wantClientAuth = false, needClientAuth = true).toSSLParameters
params.getWantClientAuth shouldBe false
params.getNeedClientAuth shouldBe true
}

"needClientAuth when wantClientAuth=true and needClientAuth=true" in {
val params = TLSParameters(wantClientAuth = true, needClientAuth = true).toSSLParameters
params.getWantClientAuth shouldBe false
params.getNeedClientAuth shouldBe true
}
}
}