Skip to content

ORA-12564 error when TNS descriptor contains double-quoted values (e.g. SSL_SERVER_CERT_DN, SERVICE_NAME) #763

Closed

Description

@mfielding

Description

TNS connect descriptors may wrap parameter values in double quotes. This is the form Oracle publishes for Autonomous Database (tnsnames.ora downloaded from the OCI console), where ssl_server_cert_dn contains commas:

(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-ashburn-1.oraclecloud.com))(connect_data=(service_name=xxxx_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))

go-ora fails to connect with such descriptors, in both v2 and v3:

  1. Quoted values sent on the wire. go-ora forwards the descriptor to the listener unchanged, including the double quotes. The listener rejects the connect packet and the client receives ORA-12564: TNS:connection refused. The Oracle Instant Client strips the outer quotes before sending the connect packet (verified by capturing both clients' connect packets against a local TCP listener).
  2. Quoted SERVICE_NAME not parsed. SERVICE_NAME="my_service" does not match the SERVICE_NAME regex in configurations/database_info.go ([\w.-]+), so the service name is not extracted.
  3. Commas split in BuildJDBC/BuildUrl. BuildUrl splits every option value on , and emits one query parameter per fragment. For the connStr option this breaks the descriptor at every comma inside the DN, so ssl_server_cert_dn values with commas cannot be passed through BuildJDBC.

Reproduction

connStr := `(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=host)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=svc))(SECURITY=(SSL_SERVER_CERT_DN="CN=adwc, O=Oracle, C=US")))`
url := go_ora.BuildJDBC("user", "pass", connStr, map[string]string{"SSL": "true", "WALLET": "/path/to/wallet"})
db, _ := sql.Open("oracle", url)
err := db.Ping() // ORA-12564

With the same descriptor, the Oracle Instant Client (thick mode) connects successfully.

Expected behaviour

go-ora matches the Oracle client: outer double quotes on descriptor values are stripped before local parsing and before the connect packet is serialized, and connStr passed through BuildJDBC is preserved intact.

Versions

  • go-ora: v2 (master) and v3 (master)
  • Database: Oracle Autonomous Database 19c and 26ai, TCPS with wallet

Fix proposed in #741.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions