Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
17c7a0a
prep for v0.21.0 (#99)
shueybubbles Mar 28, 2023
327d048
feat: Add admin protocol for DAC (#110)
shueybubbles May 25, 2023
48240e4
Update go package dependencies
apoorvdeshmukh May 30, 2023
70e2d2b
Update go package dependencies
apoorvdeshmukh May 30, 2023
1457717
Enable dependabot for pkg updates
apoorvdeshmukh Jun 16, 2023
c30824f
fix: npipe dialer now returns immediately on pipe not found
shueybubbles Jun 16, 2023
dd3e503
Enable dependabot for pkg updates
apoorvdeshmukh Jun 16, 2023
78ad891
fix: mips and mipsel builds (#124)
powersj Jun 30, 2023
3cc2463
Accept additional values for encrypt
apoorvdeshmukh Jul 6, 2023
45ecf99
Allow for local dns resolution with a custom dialer (#121)
stephaniehingtgen Jul 11, 2023
0424103
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Jul 11, 2023
b607336
Fixes MarshalText and adds UnmarshalJSON interface for UniqueIdentifi…
Musab-Nazir Jul 11, 2023
2534789
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Jul 13, 2023
386a3fc
Enable TDS 8.0 is encrypt is strict
apoorvdeshmukh Jul 14, 2023
c789659
fix: protocol version
Jul 15, 2023
ff5b16d
Merge pull request #131 from srdan-bozovic-msft/srbozovi/tds8
apoorvdeshmukh Jul 17, 2023
0c13c27
Update README.md
dlevy-msft Jul 17, 2023
7a2e1b2
Merge pull request #132 from microsoft/dlevy-msft-patch-1
dlevy-msft Jul 17, 2023
d3fae84
prep for tag 1.4 (#134)
shueybubbles Jul 20, 2023
3333338
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Jul 25, 2023
7804e0c
Fix: Handle extended chars in SQL instance names (#138)
shueybubbles Jul 25, 2023
435d861
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Jul 27, 2023
adee951
Keep certificate in PEM format explicitly to support other formats
apoorvdeshmukh Jul 27, 2023
514012a
Start Always Encrypted feature branch (#116)
shueybubbles Aug 10, 2023
af86594
Update README.md Title
dlevy-msft Aug 14, 2023
6318536
Merge pull request #143 from microsoft/dlevy-msft-patch-1
dlevy-msft Aug 14, 2023
ad2cf66
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Aug 17, 2023
6b69560
Feat: Implement change password during login (#141)
shueybubbles Aug 21, 2023
1e53bf7
Add TDS8 testcase
apoorvdeshmukh Aug 22, 2023
79c823e
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Aug 22, 2023
eb38425
feat: Implement AKV key provider for always encrypted (#148)
shueybubbles Aug 22, 2023
291c8eb
Address review suggestions
apoorvdeshmukh Aug 22, 2023
63ba4b4
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Aug 24, 2023
fb026c1
Add note on CLI authentication
dlevy-msft Aug 24, 2023
18ea4dc
Modify testcases and update README
apoorvdeshmukh Aug 31, 2023
e91b8c1
Change const
apoorvdeshmukh Aug 31, 2023
77786ad
feat: Add device code and Az CLI auth types to azuread (#149)
shueybubbles Aug 31, 2023
7da34ad
Correct transport check
apoorvdeshmukh Aug 31, 2023
d090602
Use testify for asserts
apoorvdeshmukh Aug 31, 2023
4137aa2
Merge remote-tracking branch 'origin/main' into apoorvdeshmukh/tds8
apoorvdeshmukh Aug 31, 2023
36bf0bc
Correct test expectation
apoorvdeshmukh Aug 31, 2023
7a47b91
handle AKV key name collision
shueybubbles Aug 31, 2023
8ee6a31
Merge branch 'apoorvdeshmukh/tds8' of https://github.com/microsoft/go…
shueybubbles Aug 31, 2023
d611ee3
Update README.md
dlevy-msft Aug 31, 2023
2c72afb
Add TDS8 support
apoorvdeshmukh Aug 31, 2023
80cf4b6
Merge pull request #151 from microsoft/dlevy-msft-patch-2
dlevy-msft Sep 1, 2023
12069dc
Add support for DER certificates
apoorvdeshmukh Sep 5, 2023
df78a90
Add unit test for readCertificate
apoorvdeshmukh Sep 12, 2023
8f2a85c
Minor test tweaks
apoorvdeshmukh Sep 12, 2023
d3f844a
fix(CharsetToUTF8): use strings.Builder (#154)
konart Sep 14, 2023
d229b26
Refine test
apoorvdeshmukh Sep 19, 2023
e51fa15
Add support for DER certificates
apoorvdeshmukh Sep 20, 2023
670fd58
Replace panic with returning errors from key decryption providers (#155)
shueybubbles Oct 18, 2023
2b177e8
Feat: Allow krb5 config through environment variables (#157)
shueybubbles Oct 19, 2023
c902b67
fix: Added multisubnetfailover option, set to false to prevent issue …
abairmj Oct 19, 2023
5738a68
Fix mappings between LCIDs and code pages. (#169)
shueybubbles Jan 23, 2024
5821c4e
Cut string output parameter fix (#168)
El-76 Jan 23, 2024
b650081
Lazy initialization of charset maps (#166)
toddtreece Feb 14, 2024
f37ff1d
Handle alternate form of prelogin response (#175)
shueybubbles Feb 21, 2024
fe7c3d4
Feat: Add NullableUniqueIdentifier type
ngehrsitz Feb 21, 2024
80b58f2
Fix: Support nullable types in Always Encrypted (#179)
shueybubbles Mar 6, 2024
ada30cb
Fix named pipe path handling to preserve "." (#178)
shueybubbles Mar 19, 2024
b3a8513
fix: support nullable types for bulkcopy (#192)
vecknishwaran May 23, 2024
3ed002a
fix: use proper scope for Entra auth (#198)
shueybubbles May 30, 2024
a1c982b
Fix: handle sql.NullTime parameters (#195)
shueybubbles May 30, 2024
2395b78
Migrate managed identity example to azidentity (#199)
chlowell Jun 10, 2024
9b84d9b
Vulnerabilty dependency x/net (#203)
tulioncds Jun 28, 2024
02deabf
Support for UDT (hierarchyid, geometry and geography) (#216)
tentone Aug 22, 2024
573423d
Fix: Connection not closed when database name is incorrect #173 fix (…
parMaster Oct 14, 2024
4b95a0f
Fix error checks during certificatePath reading and parsing in azurea…
jegorbunov Nov 26, 2024
2521238
Bump github.com/Azure/azure-sdk-for-go/sdk/azidentity (#229)
dependabot[bot] Dec 2, 2024
dad23d2
Feat: Add tracing data to prelogin and login7 packets (#228)
shueybubbles Dec 5, 2024
ba24acc
Fix GUID conversion (#207)
andrea-mgn Feb 19, 2025
d27f997
Try to fix the github PR validation workflow (#240)
shueybubbles Mar 7, 2025
e804768
Add JSON-encoded version of NULL uniqueidentifier (#238)
sedbygo Apr 14, 2025
b9933eb
DATETIME: fix 1/300 of a seconds rounding logic (Bulk Copy related) (…
jegorbunov Apr 14, 2025
549c925
isProc: recognize builtin-commands (#252)
giautm Apr 28, 2025
46d39b9
bump: github.com/golang-jwt/jwt/v5 v5.2.1 => v5.2.2 (#256)
yuri-potatoq Apr 28, 2025
6b3e174
replace ioutil with io everywhere (#258)
adrianosela May 9, 2025
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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
10 changes: 4 additions & 6 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.16','1.17', '1.18']
sqlImage: ['2017-latest','2019-latest']
go: ['1.19','1.20']
sqlImage: ['2019-latest','2022-latest']
steps:
- uses: actions/checkout@v2
- name: Setup go
Expand All @@ -21,13 +21,11 @@ jobs:
- name: Run tests against Linux SQL
run: |
go version
go get -d
export SQLCMDPASSWORD=$(date +%s|sha256sum|base64|head -c 32)
export SQLCMDUSER=sa
export SQLUSER=sa
export SQLPASSWORD=$SQLCMDPASSWORD
export DATABASE=test
export DATABASE=master
docker run -m 2GB -e ACCEPT_EULA=1 -d --name sqlserver -p:1433:1433 -e SA_PASSWORD=$SQLCMDPASSWORD mcr.microsoft.com/mssql/server:${{ matrix.sqlImage }}
sleep 10
sqlcmd -Q "CREATE DATABASE test"
go test -race -cpu 4 ./...
go test -v ./...
4 changes: 2 additions & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
uses: reviewdog/action-golangci-lint@v2
with:
level: warning
reporter: github-pr-review
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: "2"
linters:
enable:
# basic go linters
- gofmt
- golint
- govet
- revive # replacing golint as it is deprecated

# sql related linters
- rowserrcheck
Expand Down
16 changes: 6 additions & 10 deletions .pipelines/TestSql2017.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ variables:
steps:
- task: GoTool@0
inputs:
version: '1.16.5'
- task: Go@0
displayName: 'Go: get sources'
inputs:
command: 'get'
arguments: '-d'
workingDirectory: '$(Build.SourcesDirectory)'

version: '1.22.10'

- task: Go@0
displayName: 'Go: install gotest.tools/gotestsum'
Expand All @@ -41,8 +34,6 @@ steps:
arguments: 'github.com/AlekSi/gocov-xml@latest'
workingDirectory: '$(System.DefaultWorkingDirectory)'

#Your build pipeline references an undefined variables named SQLPASSWORD and AZURESERVER_DSN.
#Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

- task: Docker@2
displayName: 'Run SQL 2017 docker image'
Expand All @@ -61,6 +52,11 @@ steps:
SQLPASSWORD: $(SQLPASSWORD)
AZURESERVER_DSN: $(AZURESERVER_DSN)
SQLSERVER_DSN: $(SQLSERVER_DSN)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
KEY_VAULT_NAME: $(KEY_VAULT_NAME)
AZURE_TENANT_ID: $(AZURE_TENANT_ID)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
COLUMNENCRYPTION: 1
continueOnError: true
- task: PublishTestResults@2
displayName: "Publish junit-style results"
Expand Down
73 changes: 70 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,82 @@
# Changelog
## 1.7.0

## [Unreleased]
### Changed

* Changed always encrypted key provider error handling not to panic on failure

### Features

* Support DER certificates for server authentication (#152)

### Bug fixes

* Improved speed of CharsetToUTF8 (#154)

## 1.7.0

### Changed

* krb5 authenticator supports standard Kerberos environment variables for configuration

## 1.6.0

### Changed

* Go.mod updated to Go 1.17
* Azure SDK for Go dependencies updated

### Features

* Added `ActiveDirectoryAzCli` and `ActiveDirectoryDeviceCode` authentication types to `azuread` package
* Always Encrypted encryption and decryption with 2 hour key cache (#116)
* 'pfx', 'MSSQL_CERTIFICATE_STORE', and 'AZURE_KEY_VAULT' encryption key providers
* TDS8 can now be used for connections by setting encrypt="strict"

## 1.5.0

### Features

### Bug fixes

* Handle extended character in SQL instance names for browser lookup (#122)

## 1.4.0

### Features

* Adds UnmarshalJSON interface for UniqueIdentifier (#126)

### Bug fixes

* Fixes MarshalText prototype for UniqueIdentifier

## 1.2.0

### Features

* A connector's dialer can now be used to resolve DNS if the dialer implements the `HostDialer` interface

## 1.0.0

### Features

* `admin` protocol for dedicated administrator connections

### Changed

* Added `Hidden()` method to `ProtocolParser` interface

## 0.21.0

### Features

* Updated azidentity to 1.2.1, which adds in memory cache for managed credentials
* Updated azidentity to 1.2.1, which adds in memory cache for managed credentials ([#90](https://github.com/microsoft/go-mssqldb/pull/90))

### Bug fixes

* Fixed uninitialized server name in TLS config ([#93](https://github.com/microsoft/go-mssqldb/issues/93))([#94](https://github.com/microsoft/go-mssqldb/pull/94))
* Fixed several kerberos authentication usages on Linux with new krb5 authentication provider.
* Fixed several kerberos authentication usages on Linux with new krb5 authentication provider. ([#65](https://github.com/microsoft/go-mssqldb/pull/65))

### Changed

Expand Down
103 changes: 93 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# A pure Go MSSQL driver for Go's database/sql package
# Microsoft's official Go MSSQL driver

[![Go Reference](https://pkg.go.dev/badge/github.com/microsoft/go-mssqldb.svg)](https://pkg.go.dev/github.com/microsoft/go-mssqldb)
[![Build status](https://ci.appveyor.com/api/projects/status/jrln8cs62wj9i0a2?svg=true)](https://ci.appveyor.com/project/microsoft/go-mssqldb)
[![codecov](https://codecov.io/gh/microsoft/go-mssqldb/branch/master/graph/badge.svg)](https://codecov.io/gh/microsoft/go-mssqldb)

For more recent updates, see the [Microsoft fork](https://github.com/microsoft/go-mssqldb).

## Install

Requires Go 1.8 or above.
Requires Go 1.17 or above.

Install with `go install github.com/microsoft/go-mssqldb@latest`.

Expand All @@ -26,9 +25,10 @@ Other supported formats are listed below.
* `connection timeout` - in seconds (default is 0 for no timeout), set to 0 for no timeout. Recommended to set to 0 and use context to manage query and connection timeouts.
* `dial timeout` - in seconds (default is 15 times the number of registered protocols), set to 0 for no timeout.
* `encrypt`
* `strict` - Data sent between client and server is encrypted E2E using [TDS8](https://learn.microsoft.com/en-us/sql/relational-databases/security/networking/tds-8?view=sql-server-ver16).
* `disable` - Data send between client and server is not encrypted.
* `false` - Data sent between client and server is not encrypted beyond the login packet. (Default)
* `true` - Data sent between client and server is encrypted.
* `false`/`optional`/`no`/`0`/`f` - Data sent between client and server is not encrypted beyond the login packet. (Default)
* `true`/`mandatory`/`yes`/`1`/`t` - Data sent between client and server is encrypted.
* `app name` - The application name (default is go-mssqldb)
* `authenticator` - Can be used to specify use of a registered authentication provider. (e.g. ntlm, winsspi (on windows) or krb5 (on linux))

Expand Down Expand Up @@ -57,13 +57,18 @@ Other supported formats are listed below.
* `TrustServerCertificate`
* false - Server certificate is checked. Default is false if encrypt is specified.
* true - Server certificate is not checked. Default is true if encrypt is not specified. If trust server certificate is true, driver accepts any certificate presented by the server and any host name in that certificate. In this mode, TLS is susceptible to man-in-the-middle attacks. This should be used only for testing.
* `certificate` - The file that contains the public key certificate of the CA that signed the SQL Server certificate. The specified certificate overrides the go platform specific CA certificates.
* `certificate` - The file that contains the public key certificate of the CA that signed the SQL Server certificate. The specified certificate overrides the go platform specific CA certificates. Currently, certificates of PEM type are supported.
* `hostNameInCertificate` - Specifies the Common Name (CN) in the server certificate. Default value is the server host.
* `tlsmin` - Specifies the minimum TLS version for negotiating encryption with the server. Recognized values are `1.0`, `1.1`, `1.2`, `1.3`. If not set to a recognized value the default value for the `tls` package will be used. The default is currently `1.2`.
* `ServerSPN` - The kerberos SPN (Service Principal Name) for the server. Default is MSSQLSvc/host:port.
* `Workstation ID` - The workstation name (default is the host name)
* `ApplicationIntent` - Can be given the value `ReadOnly` to initiate a read-only connection to an Availability Group listener. The `database` must be specified when connecting with `Application Intent` set to `ReadOnly`.
* `protocol` - forces use of a protocol. Make sure the corresponding package is imported.
* `columnencryption` or `column encryption setting` - a boolean value indicating whether Always Encrypted should be enabled on the connection.
* `multisubnetfailover`
* `true` (Default) Client attempt to connect to all IPs simultaneously.
* `false` Client attempts to connect to IPs in serial.
* `guid conversion` - Enables the conversion of GUIDs, so that byte order is preserved. UniqueIdentifier isn't supported for nullable fields, NullUniqueIdentifier must be used instead.

### Connection parameters for namedpipe package
* `pipe` - If set, no Browser query is made and named pipe used will be `\\<host>\pipe\<pipe>`
Expand All @@ -72,6 +77,10 @@ Other supported formats are listed below.

If no pipe name can be derived from the DSN, connection attempts will first query the SQL Browser service to find the pipe name for the instance.

### DNS Resolution through a Custom Dialer

Custom Dialers can be used to resolve DNS if the Connection's Dialer implements the `HostDialer` interface. This is helpful when the dialer is proxying requests to a different, private network and the DNS record is local to the private network.

### Protocol configuration

To force a specific protocol for the connection there two several options:
Expand All @@ -80,6 +89,8 @@ To force a specific protocol for the connection there two several options:

`msdsn.ProtocolParsers` can be reordered to prioritize other protocols ahead of `tcp`

The `admin` protocol will not be used for dialing unless the connection string explicitly specifies it. Note SQL Server allows only 1 admin (or DAC) connection to be active at a time.

### Kerberos Active Directory authentication outside Windows

To connect with kerberos authentication from a Linux server you can use the optional krb5 package.
Expand Down Expand Up @@ -117,10 +128,10 @@ The package supports authentication via 3 methods.
### Kerberos Parameters

* `authenticator` - set this to `krb5` to enable kerberos authentication. If this is not present, the default provider would be `ntlm` for unix and `winsspi` for windows.
* `krb5-configfile` (mandatory) - path to kerberos configuration file.
* `krb5-realm` (required with keytab and raw credentials) - Domain name for kerberos authentication.
* `krb5-keytabfile` - path to Keytab file.
* `krb5-credcachefile` - path to Credential cache.
* `krb5-configfile` (optional) - path to kerberos configuration file. Defaults to `/etc/krb5.conf`. Can also be set using `KRB5_CONFIG` environment variable.
* `krb5-realm` (required with keytab and raw credentials) - Domain name for kerberos authentication. Omit this parameter if the realm is part of the user name like `username@REALM`.
* `krb5-keytabfile` - path to Keytab file. Can also be set using environment variable `KRB5_KTNAME`. If no parameter or environment variable is set, the `DefaultClientKeytabName` value from the krb5 config file is used.
* `krb5-credcachefile` - path to Credential cache. Can also be set using environment variable `KRBCCNAME`.
* `krb5-dnslookupkdc` - Optional parameter in all contexts. Set to lookup KDCs in DNS. Boolean. Default is true.
* `krb5-udppreferencelimit` - Optional parameter in all contexts. 1 means to always use tcp. MIT krb5 has a default value of 1465, and it prevents user setting more than 32700. Integer. Default is 1.

Expand Down Expand Up @@ -195,6 +206,16 @@ For further information on usage:
Azure Active Directory authentication uses temporary authentication tokens to authenticate.
The `mssql` package does not provide an implementation to obtain tokens: instead, import the `azuread` package and use driver name `azuresql`. This driver uses [azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#section-readme) to acquire tokens using a variety of credential types.

To reduce friction in local development, `ActiveDirectoryDefault` can authenticate as the user signed into the Azure CLI.

Run the following command to sign into the Azure CLI before running your application using the `ActiveDirectoryDefault` connection string parameter:

```azurecli
az login
```

Azure CLI authentication isn't recommended for applications running in Azure. More details are available via the [Azure authentication with the Azure Identity module for Go](https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication) tutorial.

The credential type is determined by the new `fedauth` connection string parameter.

* `fedauth=ActiveDirectoryServicePrincipal` or `fedauth=ActiveDirectoryApplication` - authenticates using an Azure Active Directory application client ID and client secret or certificate. Implemented using [ClientSecretCredential or CertificateCredential](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/azidentity#authenticating-service-principals)
Expand All @@ -211,6 +232,8 @@ The credential type is determined by the new `fedauth` connection string paramet
* `resource id=<resource id>` - optional resource id of user-assigned managed identity. If empty, system-assigned managed identity or user id are used (if both user id and resource id are provided, resource id will be used)
* `fedauth=ActiveDirectoryInteractive` - authenticates using credentials acquired from an external web browser. Only suitable for use with human interaction.
* `applicationclientid=<application id>` - This guid identifies an Azure Active Directory enterprise application that the AAD admin has approved for accessing Azure SQL database resources in the tenant. This driver does not have an associated application id of its own.
* `fedauth=ActiveDirectoryDeviceCode` - prints a message to stdout giving the user a URL and code to authenticate. Connection continues after user completes the login separately.
* `fedauth=ActiveDirectoryAzCli` - reuses local authentication the user already performed using Azure CLI.

```go

Expand Down Expand Up @@ -372,8 +395,62 @@ db.QueryContext(ctx, `select * from t2 where user_name = @p1;`, mssql.VarChar(na
// Note: Mismatched data types on table and parameter may cause long running queries
```

## Using Always Encrypted

The protocol and cryptography details for AE are [detailed elsewhere](https://learn.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-ver16).

### Enablement

To enable AE on a connection, set the `ColumnEncryption` value to true on a config or pass `columnencryption=true` in the connection string.

Decryption and encryption won't succeed, however, without also including a decryption key provider. To avoid code size impacts on non-AE applications, key providers are not included by default.

Include the local certificate providers:

```go
import (
"github.com/microsoft/go-mssqldb/aecmk/localcert"
)
```

You can also instantiate a key provider directly in code and hand it to a `Connector` instance.

```go
c := mssql.NewConnectorConfig(myconfig)
c.RegisterCekProvider(providerName, MyProviderType{})
```

### Decryption

If the correct key provider is included in your application, decryption of encrypted cells happens automatically with no extra server round trips.

### Encryption

Encryption of parameters passed to `Exec` and `Query` variants requires an extra round trip per query to fetch the encryption metadata. If the error returned by a query attempt indicates a type mismatch between the parameter and the destination table, most likely your input type is not a strict match for the SQL Server data type of the destination. You may be using a Go `string` when you need to use one of the driver-specific aliases like `VarChar` or `NVarCharMax`.

*** NOTE *** - Currently `char` and `varchar` types do not include a collation parameter component so can't be used for inserting encrypted values.
https://github.com/microsoft/go-mssqldb/issues/129


### Local certificate AE key provider

Key provider configuration is managed separately without any properties in the connection string.
The `pfx` provider exposes its instance as the variable `PfxKeyProvider`. You can give it passwords for certificates using `SetCertificatePassword(pathToCertificate, path)`. Use an empty string or `"*"` as the path to use the same password for all certificates.

The `MSSQL_CERTIFICATE_STORE` provider exposes its instance as the variable `WindowsCertificateStoreKeyProvider`.

Both providers can be constrained to an allowed list of encryption key paths by appending paths to `provider.AllowedLocations`.


### Azure Key Vault (AZURE_KEY_VAULT) key provider

Import this provider using `github.com/microsoft/go-mssqldb/aecmk/akv`

Constrain the provider to an allowed list of key vaults by appending vault host strings like "mykeyvault.vault.azure.net" to `akv.KeyProvider.AllowedLocations`.

## Important Notes


* [LastInsertId](https://golang.org/pkg/database/sql/#Result.LastInsertId) should
not be used with this driver (or SQL Server) due to how the TDS protocol
works. Please use the [OUTPUT Clause](https://docs.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql)
Expand All @@ -400,9 +477,14 @@ db.QueryContext(ctx, `select * from t2 where user_name = @p1;`, mssql.VarChar(na
* Supports connections to AlwaysOn Availability Group listeners, including re-direction to read-only replicas.
* Supports query notifications
* Supports Kerberos Authentication
* Supports handling the `uniqueidentifier` data type with the `UniqueIdentifier` and `NullUniqueIdentifier` go types
* Pluggable Dialer implementations through `msdsn.ProtocolParsers` and `msdsn.ProtocolDialers`
* A `namedpipe` package to support connections using named pipes (np:) on Windows
* A `sharedmemory` package to support connections using shared memory (lpc:) on Windows
* Dedicated Administrator Connection (DAC) is supported using `admin` protocol
* Always Encrypted
- `MSSQL_CERTIFICATE_STORE` provider on Windows
- `pfx` provider on Linux and Windows

## Tests

Expand Down Expand Up @@ -443,6 +525,7 @@ To fix SQL Server 2008 R2 issue, install SQL Server 2008 R2 Service Pack 2.
To fix SQL Server 2008 issue, install Microsoft SQL Server 2008 Service Pack 3 and Cumulative update package 3 for SQL Server 2008 SP3.
More information: <http://support.microsoft.com/kb/2653857>

* Bulk copy does not yet support encrypting column values using Always Encrypted. Tracked in [#127](https://github.com/microsoft/go-mssqldb/issues/127)

# Contributing
This project is a fork of [https://github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) and welcomes new and previous contributors. For more informaton on contributing to this project, please see [Contributing](./CONTRIBUTING.md).
Expand Down
Loading