From 1d82d6f3a99317d3a609c41fc1619d6308940805 Mon Sep 17 00:00:00 2001 From: "liviu.ungureanu" Date: Mon, 20 Jan 2020 12:04:58 +0000 Subject: [PATCH] add more tls support --- build.sbt | 4 ++-- .../com/spingo/op_rabbit/ConnectionParams.scala | 16 ++++++++++++++-- project/version.properties | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 0c1cb08..cfec4cc 100644 --- a/build.sbt +++ b/build.sbt @@ -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" @@ -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", diff --git a/core/src/main/scala/com/spingo/op_rabbit/ConnectionParams.scala b/core/src/main/scala/com/spingo/op_rabbit/ConnectionParams.scala index d20b604..59650c7 100644 --- a/core/src/main/scala/com/spingo/op_rabbit/ConnectionParams.scala +++ b/core/src/main/scala/com/spingo/op_rabbit/ConnectionParams.scala @@ -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 @@ -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 = { @@ -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() + } + } } } diff --git a/project/version.properties b/project/version.properties index 16cc23c..4111d6e 100644 --- a/project/version.properties +++ b/project/version.properties @@ -1 +1 @@ -version=2.1.0 \ No newline at end of file +version=2.1.1-1 \ No newline at end of file