Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions connection_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ var propertyEndpoint = createConnectionProperty(
connectionstate.ContextStartup,
connectionstate.ConvertString,
)
var propertyAuthority = createConnectionProperty(
"authority",
"The expected server name in the TLS handshake. By default, the endpoint hostname is used. This option "+
"is useful when connecting to Spanner via Google Private Connect or other custom endpoints where the "+
"endpoint hostname does not match the server’s TLS certificate.",
"",
false,
nil,
connectionstate.ContextStartup,
connectionstate.ConvertString,
)
var propertyCredentials = createConnectionProperty(
"credentials",
"The location of the credentials file to use for this connection. If neither this property or encoded "+
Expand Down
8 changes: 8 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ type ConnectorConfig struct {
// Leave this empty to use the standard Spanner API endpoint.
Host string

// The expected server name in the TLS handshake.
// Leave this empty to use the endpoint hostname.
Authority string

// Project, Instance, and Database identify the database that the connector
// should create connections for.
Project string
Expand Down Expand Up @@ -568,6 +572,10 @@ func createConnector(d *Driver, connectorConfig ConnectorConfig) (*connector, er
if connectorConfig.Host != "" {
opts = append(opts, option.WithEndpoint(connectorConfig.Host))
}
assignPropertyValueIfExists(state, propertyAuthority, &connectorConfig.Authority)
if connectorConfig.Authority != "" {
opts = append(opts, option.WithGRPCDialOption(grpc.WithAuthority(connectorConfig.Authority)))
}
if val := propertyCredentials.GetValueOrDefault(state); val != "" {
opts = append(opts, option.WithCredentialsFile(val))
}
Expand Down
Loading