negotiate

fun negotiate(stream: PgStream, host: String, port: Int, config: SslConfiguration)

Asks the server for TLS and upgrades the connection if it agrees, before the startup message and so before any credential is on the wire.

What a refusal means is io.github.octaviusframework.driver.properties.SslMode's to say: under DISABLE nothing is asked at all, under the permissive modes a refusal continues in plaintext, and under REQUIRE and stronger it is a failure.

Parameters

stream

The connection to upgrade in place.

host

The host, for hostname verification under the verifying modes.

port

The port, used when reporting a failure.

config

What was asked for: mode, certificates and key.

Throws

SSL_ERROR if the server refuses under a mode that requires TLS, or answers the request with something that is not a yes or a no.