Main issues related to ssl/client cert:
-
Even when I start cockroachdb in --insecure mode to avoid ssl and cert issues, I am unable to connect and the connection callback from client.getConnection
is never called (it hangs), whereas using the jdbc driver with the same config I connect successfully. So I see the log statement from LOG.debug("CONNECTING")
but nothing more (and the process does not terminate, the web server is up). I think I should get this solved first.
-
I suspect SSL works fine but I have not been able to successfully connect; hangs as in #1.
- For SSL:
The configuration does appear support ssl but does not appear to support client certs.
Following the link, there is no ssl config info, however if you search the codebase for ssl you find an ssl impl
It supports two modes
val VerifyCA = Value(“verify-ca”) // only try an SSL connection, and verify that the server certificate is issued by a trusted certificate authority (CA)
val VerifyFull = Value(“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
ex: sslmode=verify-ca
- For the client cert:
Maybe I don’t have my cert installed via the keytool correctly - I will start over and try again.
Do you know if it “should” support client certs?
Simple example code for #1
public class MainVerticle extends AbstractVerticle {
private static final Logger LOG = LoggerFactory.getLogger(MainVerticle.class);
private Router router = Router.router(vertx);
public MainVerticle() throws Exception {
super();
}
@Override
public void start() {
JsonObject postgreSQLClientConfig = new JsonObject()
.put("host", "localhost")
.put("port", 26257)
.put("database", "mydb")
.put("username", "root")
.put("password", "stupidpwd");
SQLClient client = PostgreSQLClient.createShared(vertx, postgreSQLClientConfig);
LOG.debug("CONNECTING");
client.getConnection(res -> {
LOG.debug("GOT RESULT");
if (res.succeeded()) {
LOG.debug("CONNECTED");
SQLConnection conn = res.result();
conn.query("SELECT * FROM mydb.mytable", rs -> {
System.out.print(rs.result().getColumnNames());
System.out.print("Column 1 returned ");
});
} else {
// Failed to get connection
LOG.debug("FAIL");
}
});
HttpServer server = vertx.createHttpServer();
UserRouter.mountRoutes(vertx, router);
server.requestHandler(router::accept).listen(3000);
}
}