Skip to content

Commit

Permalink
add more tls support
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu.ungureanu committed Jan 20, 2020
1 parent aa2d838 commit 1d82d6f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.util.Properties

val json4sVersion = "3.6.6"
val circeVersion = "0.12.3"
val circeVersion = "0.12.0-M3"
val akkaVersion = "2.5.25"
val playVersion = "2.7.4"

Expand All @@ -16,7 +16,7 @@ val assertNoApplicationConf = taskKey[Unit]("Makes sure application.conf isn't p
val commonSettings = Seq(
organization := "com.spingo",
version := appProperties.getProperty("version"),
scalaVersion := "2.12.10",
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.12.10", "2.13.1"),
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.3.3",
Expand Down
16 changes: 14 additions & 2 deletions core/src/main/scala/com/spingo/op_rabbit/ConnectionParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.rabbitmq.client.SaslConfig
import com.rabbitmq.client.impl.DefaultExceptionHandler
import com.typesafe.config.Config
import javax.net.SocketFactory
import javax.net.ssl.SSLContext

import scala.collection.JavaConverters._
import scala.util.Try

Expand Down Expand Up @@ -39,7 +41,8 @@ case class ConnectionParams(
saslConfig: SaslConfig = DefaultSaslConfig.PLAIN,
sharedExecutor: Option[java.util.concurrent.ExecutorService] = None,
shutdownTimeout: Int = ConnectionFactory.DEFAULT_SHUTDOWN_TIMEOUT,
socketFactory: SocketFactory = SocketFactory.getDefault
socketFactory: SocketFactory = SocketFactory.getDefault,
sslContextOpt: Option[SSLContext] = None
) {
// TODO - eliminate ClusterConnectionFactory after switching to use RabbitMQ's topology recovery features.
protected [op_rabbit] def applyTo(factory: ClusterConnectionFactory): Unit = {
Expand All @@ -58,7 +61,16 @@ case class ConnectionParams(
sharedExecutor.foreach(factory.setSharedExecutor)
factory.setShutdownTimeout(shutdownTimeout)
factory.setSocketFactory(socketFactory)
if (ssl) factory.useSslProtocol()
if (ssl) {
sslContextOpt match {
case Some(sslContext) =>
// suitable for production
factory.useSslProtocol(sslContext)
case None =>
// suitable for development
factory.useSslProtocol()
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion project/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.1.0
version=2.1.1-1

0 comments on commit 1d82d6f

Please sign in to comment.