Repository navigation
Conversation
After a listener redirect (for example a RAC SCAN listener handing off to a node listener by VIP IP), negotiate set tls.Config.ServerName to the redirect address. Certificates issued for the SCAN host name with no IP SANs then fail verification, while JDBC and the OCI clients accept them. Record the host of the server that sent the redirect as TLSServerName on each redirect address and use it as ServerName.
negotiate set ServerName on the tls.Config passed to WithTLSConfig. That config is shared by every connection made with the connector, so concurrent connections raced on ServerName, and a handshake could be verified against the host name of another connection. Clone the config before setting ServerName. Fixes sijms#757
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a TCPS connection goes through a listener that redirects (the usual case for an Oracle RAC SCAN listener, which hands the client off to a node listener), go-ora verifies the server certificate against the redirect target instead of the host in the original connect descriptor.
SCAN listeners typically redirect to the node VIP IP address. Listener certificates, including the defaults Oracle provisions, are issued for the SCAN host name and have no IP SANs, so verification fails:
The same connect string works with JDBC thin, Instant Client, and python-oracledb (fixed there in 3.0.0, oracle/python-oracledb#415). These clients check the certificate against the host the user asked for, not the address the listener redirected to.
The only workarounds today are
SSL VERIFY=falseor a listener certificate with IP SANs for every node VIP.Cause
Session.Connecthandles aRedirectPacketby callingUpdateDatabaseInfoForRedirect, which replacesDatabaseInfo.Serverswith the addresses from the redirect.Session.negotiatethen setstls.Config.ServerName = host.Addrfor the active server, which is now the redirect address.Change
ServerAddrgets aTLSServerNamefield and aTLSHostName()method that returnsTLSServerNameif set, otherwiseAddr.UpdateDatabaseInfoForRedirectrecordsTLSHostName()of the server that sent the redirect and sets it asTLSServerNameon every redirect address. A chain of redirects keeps the original host.negotiateuseshost.TLSHostName()forServerNamein both the wallet path and the caller-suppliedtls.Configpath.Behaviour without a redirect doesn't change. Verification is not relaxed: the chain and host-name checks still run, against the host the user wrote in the connect string. If that host was an IP address, verification is against that IP, as before.
Tests
configurations/database_info_test.go: a redirect keeps the original host; a second redirect still keeps the first host;TLSHostNamedefaults toAddr.network/session_tls_test.go: TLS handshake throughnegotiateagainst a loopback server with a DNS-only certificate, after a redirect fromscan.example.comto10.0.0.42:tls.Config;scan.example.comwhen the certificate is for a different name.Without the change, both handshake tests fail with
x509: cannot validate certificate for 10.0.0.42 because it doesn't contain any IP SANs.Applied identically to v2 and v3.
Second commit: don't modify the caller's
tls.Config(fixes #757)negotiatesetServerNamedirectly on thetls.Configpassed toWithTLSConfig. That config is shared by every connection the connector makes. Concurrent connections therefore race onServerName, and a handshake can be verified against another connection's host name. The commit clones the config before settingServerName.We observed this against a two-node RAC with 16 concurrent connections built with
-race:session.go:345.ServerNameto the SCAN name between the ClientHello and the certificate check.Test:
TestNegotiateDoesNotModifyCallerTLSConfigruns four concurrentnegotiatecalls against one shared config, then checks thatServerNameon it is still empty. Without the change,-racereports a race and the check fails.Fixes #765