The SECURE_CONNECTION procedure upgrades an existing, open connection to use SSL/TLS encryption. This is typically used to initiate "StartTLS" style security on an unencrypted session.
SECURE_CONNECTION ( c IN OUT CONNECTION );
Parameters
c
The connection handle of the active session, originally returned by OPEN_CONNECTION. Because this is an IN OUT parameter, the internal state of the connection handle is updated to reflect the new secure status.
Notes
Prerequisites: To successfully negotiate a secure handshake, the connection must have been initialized with valid
ssl_cert_pathparameter during theOPEN_CONNECTIONcall.Handshake timing: This procedure performs the SSL/TLS handshake. If the remote host does not support encryption or the certificates are invalid, the procedure will raise an exception.
Operational flow: This is commonly used in protocols like SMTP where the initial connection is plaintext, and the session is upgraded to a secure channel before sensitive data (like credentials) is transmitted.
Impact of timeout: The handshake is subject to the
tx_timeoutvalue defined at the start of the connection.
Example
DECLARE c UTL_TCP.CONNECTION; BEGIN c := UTL_TCP.OPEN_CONNECTION('mail-arts.enterprisedb.com', 465, ssl_cert_path => '/etc/pki/tls/certs/sendmail.pem'); UTL_TCP.SECURE_CONNECTION (c); UTL_TCP.CLOSE_CONNECTION(c); END;