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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/main/asciidoc/groovy/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ Both the PostgreSql and MySql clients take the same configuration:
"password" : <your-password>,
"database" : <name-of-your-database>,
"charset" : <name-of-the-character-set>,
"queryTimeout" : <timeout-in-milliseconds>
"queryTimeout" : <timeout-in-milliseconds>,
"sslMode" : <"disable"|"prefer"|"require"|"verify-ca"|"verify-full">,
"sslRootCert" : <path to file with certificate>
}
----

Expand All @@ -239,4 +241,16 @@ Both the PostgreSql and MySql clients take the same configuration:
`password`:: The password to connect to the database. Default is not set, i.e. it uses no password.
`database`:: The name of the database you want to connect to. Defaults to `testdb`.
`charset`:: The name of the character set you want to use for the connection. Defaults to `UTF-8`.
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`sslMode` :: If you want to enable SSL support you should enable this parameter.
For example to connect Heroku you will need to use *prefer*.

"disable" ::: only try a non-SSL connection
"prefer" ::: first try an SSL connection; if that fails, try a non-SSL connection
"require" ::: only try an SSL connection, but don't verify Certificate Authority
"verify-ca" ::: only try an SSL connection, and verify that the server certificate is issued by a trusted
certificate authority (CA)
"verify-full" ::: only try an SSL connection, verify that the server certificate is issued by a trusted CA and
that the server host name matches that in the certificate
`sslRootCert` :: Path to SSL root certificate file. Is used if you want to verify privately issued certificate.
Refer to https://github.com/mauricio/postgresql-async[postgresql-async] documentation for more details.
18 changes: 16 additions & 2 deletions src/main/asciidoc/java/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ Both the PostgreSql and MySql clients take the same configuration:
"password" : <your-password>,
"database" : <name-of-your-database>,
"charset" : <name-of-the-character-set>,
"queryTimeout" : <timeout-in-milliseconds>
"queryTimeout" : <timeout-in-milliseconds>,
"sslMode" : <"disable"|"prefer"|"require"|"verify-ca"|"verify-full">,
"sslRootCert" : <path to file with certificate>
}
----

Expand All @@ -207,4 +209,16 @@ Both the PostgreSql and MySql clients take the same configuration:
`password`:: The password to connect to the database. Default is not set, i.e. it uses no password.
`database`:: The name of the database you want to connect to. Defaults to `testdb`.
`charset`:: The name of the character set you want to use for the connection. Defaults to `UTF-8`.
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`sslMode` :: If you want to enable SSL support you should enable this parameter.
For example to connect Heroku you will need to use *prefer*.

"disable" ::: only try a non-SSL connection
"prefer" ::: first try an SSL connection; if that fails, try a non-SSL connection
"require" ::: only try an SSL connection, but don't verify Certificate Authority
"verify-ca" ::: only try an SSL connection, and verify that the server certificate is issued by a trusted
certificate authority (CA)
"verify-full" ::: only try an SSL connection, verify that the server certificate is issued by a trusted CA and
that the server host name matches that in the certificate
`sslRootCert` :: Path to SSL root certificate file. Is used if you want to verify privately issued certificate.
Refer to https://github.com/mauricio/postgresql-async[postgresql-async] documentation for more details.
18 changes: 16 additions & 2 deletions src/main/asciidoc/js/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ Both the PostgreSql and MySql clients take the same configuration:
"password" : <your-password>,
"database" : <name-of-your-database>,
"charset" : <name-of-the-character-set>,
"queryTimeout" : <timeout-in-milliseconds>
"queryTimeout" : <timeout-in-milliseconds>,
"sslMode" : <"disable"|"prefer"|"require"|"verify-ca"|"verify-full">,
"sslRootCert" : <path to file with certificate>
}
----

Expand All @@ -245,4 +247,16 @@ Both the PostgreSql and MySql clients take the same configuration:
`password`:: The password to connect to the database. Default is not set, i.e. it uses no password.
`database`:: The name of the database you want to connect to. Defaults to `testdb`.
`charset`:: The name of the character set you want to use for the connection. Defaults to `UTF-8`.
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`sslMode` :: If you want to enable SSL support you should enable this parameter.
For example to connect Heroku you will need to use *prefer*.

"disable" ::: only try a non-SSL connection
"prefer" ::: first try an SSL connection; if that fails, try a non-SSL connection
"require" ::: only try an SSL connection, but don't verify Certificate Authority
"verify-ca" ::: only try an SSL connection, and verify that the server certificate is issued by a trusted
certificate authority (CA)
"verify-full" ::: only try an SSL connection, verify that the server certificate is issued by a trusted CA and
that the server host name matches that in the certificate
`sslRootCert` :: Path to SSL root certificate file. Is used if you want to verify privately issued certificate.
Refer to https://github.com/mauricio/postgresql-async[postgresql-async] documentation for more details.
18 changes: 16 additions & 2 deletions src/main/asciidoc/kotlin/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ Both the PostgreSql and MySql clients take the same configuration:
"password" : <your-password>,
"database" : <name-of-your-database>,
"charset" : <name-of-the-character-set>,
"queryTimeout" : <timeout-in-milliseconds>
"queryTimeout" : <timeout-in-milliseconds>,
"sslMode" : <"disable"|"prefer"|"require"|"verify-ca"|"verify-full">,
"sslRootCert" : <path to file with certificate>
}
----

Expand All @@ -239,4 +241,16 @@ Both the PostgreSql and MySql clients take the same configuration:
`password`:: The password to connect to the database. Default is not set, i.e. it uses no password.
`database`:: The name of the database you want to connect to. Defaults to `testdb`.
`charset`:: The name of the character set you want to use for the connection. Defaults to `UTF-8`.
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`sslMode` :: If you want to enable SSL support you should enable this parameter.
For example to connect Heroku you will need to use *prefer*.

"disable" ::: only try a non-SSL connection
"prefer" ::: first try an SSL connection; if that fails, try a non-SSL connection
"require" ::: only try an SSL connection, but don't verify Certificate Authority
"verify-ca" ::: only try an SSL connection, and verify that the server certificate is issued by a trusted
certificate authority (CA)
"verify-full" ::: only try an SSL connection, verify that the server certificate is issued by a trusted CA and
that the server host name matches that in the certificate
`sslRootCert` :: Path to SSL root certificate file. Is used if you want to verify privately issued certificate.
Refer to https://github.com/mauricio/postgresql-async[postgresql-async] documentation for more details.
18 changes: 16 additions & 2 deletions src/main/asciidoc/ruby/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ Both the PostgreSql and MySql clients take the same configuration:
"password" : <your-password>,
"database" : <name-of-your-database>,
"charset" : <name-of-the-character-set>,
"queryTimeout" : <timeout-in-milliseconds>
"queryTimeout" : <timeout-in-milliseconds>,
"sslMode" : <"disable"|"prefer"|"require"|"verify-ca"|"verify-full">,
"sslRootCert" : <path to file with certificate>
}
----

Expand All @@ -245,4 +247,16 @@ Both the PostgreSql and MySql clients take the same configuration:
`password`:: The password to connect to the database. Default is not set, i.e. it uses no password.
`database`:: The name of the database you want to connect to. Defaults to `testdb`.
`charset`:: The name of the character set you want to use for the connection. Defaults to `UTF-8`.
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
`sslMode` :: If you want to enable SSL support you should enable this parameter.
For example to connect Heroku you will need to use *prefer*.

"disable" ::: only try a non-SSL connection
"prefer" ::: first try an SSL connection; if that fails, try a non-SSL connection
"require" ::: only try an SSL connection, but don't verify Certificate Authority
"verify-ca" ::: only try an SSL connection, and verify that the server certificate is issued by a trusted
certificate authority (CA)
"verify-full" ::: only try an SSL connection, verify that the server certificate is issued by a trusted CA and
that the server host name matches that in the certificate
`sslRootCert` :: Path to SSL root certificate file. Is used if you want to verify privately issued certificate.
Refer to https://github.com/mauricio/postgresql-async[postgresql-async] documentation for more details.
16 changes: 15 additions & 1 deletion src/main/java/io/vertx/ext/asyncsql/impl/BaseSQLClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool;
import io.vertx.ext.sql.SQLConnection;
import scala.Option;
import scala.Tuple2;
import scala.collection.Map$;
import scala.collection.immutable.Map;
import scala.concurrent.ExecutionContext;
import scala.concurrent.duration.Duration;

Expand Down Expand Up @@ -117,14 +119,16 @@ protected Configuration getConfiguration(
Option<Duration> queryTimeoutOption = (queryTimeout == null) ?
Option.empty() : Option.apply(Duration.apply(queryTimeout, TimeUnit.MILLISECONDS));

Map<String, String> sslConfig = buildSslConfig(config);

log.info("Creating configuration for " + host + ":" + port);
return new Configuration(
username,
host,
port,
Option.apply(password),
Option.apply(database),
SSLConfiguration.apply(Map$.MODULE$.empty()),
SSLConfiguration.apply(sslConfig),
charset,
16777216,
PooledByteBufAllocator.DEFAULT,
Expand All @@ -133,5 +137,15 @@ protected Configuration getConfiguration(
queryTimeoutOption);
}

private Map<String, String> buildSslConfig(JsonObject config) {
Map<String, String> sslConfig = Map$.MODULE$.empty();
if (config.getString("sslMode")!= null) {
sslConfig = sslConfig.$plus(Tuple2.apply("sslmode", config.getString("sslMode")));
}
if (config.getString("sslRootCert") != null) {
sslConfig = sslConfig.$plus(Tuple2.apply("sslrootcert", config.getString("sslRootCert")));
}
return sslConfig;
}

}
16 changes: 15 additions & 1 deletion src/main/java/io/vertx/ext/asyncsql/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@
* "password" : <your-password>,
* "database" : <name-of-your-database>,
* "charset" : <name-of-the-character-set>,
* "queryTimeout" : <timeout-in-milliseconds>
* "queryTimeout" : <timeout-in-milliseconds>,
* "sslMode" : <"disable"|"prefer"|"require"|"verify-ca"|"verify-full">,
* "sslRootCert" : <path to file with certificate>
* }
* ----
*
Expand All @@ -197,6 +199,18 @@
* `database`:: The name of the database you want to connect to. Defaults to `testdb`.
* `charset`:: The name of the character set you want to use for the connection. Defaults to `UTF-8`.
* `queryTimeout`:: The timeout to wait for a query in milliseconds. Defaults to `10000` (= 10 seconds).
* `sslMode` :: If you want to enable SSL support you should enable this parameter.
* For example to connect Heroku you will need to use *prefer*.
*
* "disable" ::: only try a non-SSL connection
* "prefer" ::: first try an SSL connection; if that fails, try a non-SSL connection
* "require" ::: only try an SSL connection, but don't verify Certificate Authority
* "verify-ca" ::: only try an SSL connection, and verify that the server certificate is issued by a trusted
* certificate authority (CA)
* "verify-full" ::: only try an SSL connection, verify that the server certificate is issued by a trusted CA and
* that the server host name matches that in the certificate
* `sslRootCert` :: Path to SSL root certificate file. Is used if you want to verify privately issued certificate.
* Refer to https://github.com/mauricio/postgresql-async[postgresql-async] documentation for more details.
*/
@Document(fileName = "index.adoc")
@ModuleGen(name = "vertx-mysql-postgresql", groupPackage = "io.vertx") package io.vertx.ext.asyncsql;
Expand Down