Skip to content

Commit 9b55ffd

Browse files
committed
Drop Visual C++ installation check and update user guide.
I took a closer look at this and found a helpful doc page: https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170#notes. The Visual C++ version should be the same (or higher) as the version used to build the provider, which in our case is 14.34 because IIUC that's what comes pre-installed in the windows2019 kokoro image. Let's drop the check for now as discussed, which results in the not-as-friendly error message that I have added to the user guide. At least it won't block user installation. Note that the installer says "2015-2022" because "Visual Studio versions since Visual Studio 2015 share the same Redistributable files", per the link I shared above. Also updated the user guide doc to reflect recent changes, and fixed the new installer tests. Bug: b/288279385 Bug: b/280633307 Change-Id: Ice8ee6c5e6828bcb66b8410d36f22502db59b57b
1 parent 08425e0 commit 9b55ffd

File tree

3 files changed

+76
-16
lines changed

3 files changed

+76
-16
lines changed

kmscng/docs/user_guide.md

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
1. [Getting started](#getting-started)
66
2. [Authentication and authorization](#authentication-and-authorization)
7-
3. [Functions](#functions)
8-
4. [Cryptographic operations](#cryptographic-operations)
7+
3. [Configuration](#configuration)
8+
4. [Functions](#functions)
9+
5. [Cryptographic operations](#cryptographic-operations)
910
1. [ECDSA signing](#ecdsa-signing)
10-
5. [Limitations](#limitations)
11+
6. [Limitations](#limitations)
12+
7. [FAQs](#faqs)
1113

1214
## Getting started
1315

@@ -18,13 +20,18 @@ Official Google-built releases of this provider are covered by the
1820
If you are upgrading from a previous version of the provider, be sure to check
1921
the [change log](../../CHANGELOG.md) for changes that might affect your usage.
2022

23+
Please refer to the [FAQs section](#faqs) to troubleshoot installation or usage
24+
issues.
25+
2126
### Windows system requirements
2227

2328
The provider is built and tested on Windows Server (semi-annual channel), on the
2429
amd64 architecture. The library is designed to be compatible with Windows Server
2530
2012 R2, Windows 8.1 (x64), and all subsequent server and x64 desktop releases.
31+
2632
The provider requires the preinstallation of the Visual C++ 2022 x64
27-
Redistributable package, which can be downloaded [here][msvc-redistributable].
33+
Redistributable package (14.34 or higher), which can be downloaded
34+
[here][msvc-redistributable].
2835

2936
### Downloading and verifying the provider
3037

@@ -71,6 +78,30 @@ with the following IAM permissions:
7178
You can learn more about
7279
[managing access to Cloud KMS resources][kms-permissions-and-roles].
7380

81+
## Configuration
82+
83+
If your application uses `NCryptEnumKeys` calls, you will need to have a YAML
84+
configuration file in order to locate Cloud KMS resources. The YAML must at a
85+
minimum contain a single Cloud KMS CryptoKeyVersion.
86+
87+
Your provider configuration should be stored in `C:\Windows\KMSCNG\config.yaml`.
88+
89+
### Sample configuration file
90+
91+
```yaml
92+
---
93+
resources:
94+
- crypto_key_version: "projects/my-project/locations/us/keyRings/key-ring/cryptoKeys/my-key/cryptoKeyVersions/1"
95+
- crypto_key_version: "projects/my-project/locations/us/keyRings/other-key-ring/cryptoKeys/other-key/cryptoKeyVersions/2"
96+
```
97+
98+
### Configuration reference
99+
100+
Item Name | Type | Required | Default | Description
101+
--------------------- | ------ | -------- | ------- | -----------
102+
resources | list | Yes | None | A list of crypto_key_version entries, see field below.
103+
crypto_key_version | string | Yes | None | The full name of the KMS key version that will be made accessible.
104+
74105
## Functions
75106
76107
The provider conforms to the
@@ -85,7 +116,7 @@ Function | Status | Notes
85116
[`NCryptDeriveKey`][NCryptDeriveKey] | ❌ |
86117
[`NCryptEncrypt`][NCryptEncrypt] | ❌ |
87118
[`NCryptEnumAlgorithms`][NCryptEnumAlgorithms] | ✅ |
88-
[`NCryptEnumKeys`][NCryptEnumKeys] | |
119+
[`NCryptEnumKeys`][NCryptEnumKeys] | |
89120
[`NCryptExportKey`][NCryptExportKey] | ⚠️ | Only supports public key export, since Cloud KMS private keys cannot be exported.
90121
[`NCryptFinalizeKey`][NCryptFinalizeKey] | ❌ |
91122
[`NCryptFreeBuffer`][NCryptFreeBuffer] | ✅ |
@@ -128,6 +159,43 @@ these characteristics:
128159
The CNG provider returns an error when trying to load keys that don't conform to
129160
these requirements.
130161

162+
## FAQs
163+
164+
### Issues during installation
165+
166+
If you see this error during the installation, Visual C++ is likely not installed
167+
on your system:
168+
```
169+
There is a problem with this Windows Installer package. A DLL required for this
170+
install to complete could not be run. Contact your support personnel or package
171+
vendor.
172+
```
173+
174+
The provider requires the preinstallation of the Visual C++ 2022 x64
175+
Redistributable package (14.34 or higher), which can be downloaded
176+
[here][msvc-redistributable].
177+
178+
### gRPC Could not get default PEM root certs
179+
180+
Sample error:
181+
```
182+
W0000 00:00:1687369894.825370 1892 logging.cc:39] [external/com_github_grpc_grpc/src/core/lib/security/security_connector/ssl_utils.cc:606]: load_file: UNKNOWN:Failed to load file {filename:"/usr/share/grpc/roots.pem", created_time:"2023-06-21T17:51:34.8251349+00:00", children:[UNKNOWN:No such file or directory [...]]}
183+
W0000 00:00:1687369894.826457 1892 logging.cc:39] [external/com_github_grpc_grpc/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc:425]: Could not get default pem root certs.
184+
```
185+
186+
If you see this error, it's likely because gRPC requires an environment variable
187+
to find the root of trust for SSL. You can download the missing file and set the
188+
environment variable with:
189+
```
190+
@powershell -NoProfile -ExecutionPolicy unrestricted -Command ^
191+
(new-object System.Net.WebClient).Downloadfile( ^
192+
'https://pki.google.com/roots.pem', 'roots.pem')
193+
set GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=%cd%\roots.pem
194+
```
195+
196+
NOTE: the snippet above downloads the roots.pem file to your current directory,
197+
and sets the environment variable to point to that location.
198+
131199
[cng-key-storage-function-table]: https://learn.microsoft.com/en-us/windows/win32/seccng/cng-algorithm-identifiers
132200
[gcp-authn-getting-started]: https://cloud.google.com/docs/authentication/getting-started
133201
[gcp-authn-prod]: https://cloud.google.com/docs/authentication/production

kmscng/main/install_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func TestDoubleInstall(t *testing.T) {
127127
if !regExists(t, ctx) {
128128
t.Errorf("registry key %q is missing", registryKey)
129129
}
130-
if !dllExists(t, ctx) {
130+
if !fileExists(t, ctx, libraryFile) {
131131
t.Errorf("library file %q is missing", libraryFile)
132132
}
133133
}
@@ -141,7 +141,7 @@ func TestUninstallWithoutInstall(t *testing.T) {
141141
if regExists(t, ctx) {
142142
t.Errorf("registry key %q unexpectedly exists", registryKey)
143143
}
144-
if dllExists(t, ctx) {
144+
if fileExists(t, ctx, libraryFile) {
145145
t.Errorf("library file %q unexpectedly exists", libraryFile)
146146
}
147147
}

kmscng/main/kmscng.wxs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@
44
<Package InstallScope="perMachine" InstallerVersion="200" Compressed="yes" Platform="x64"/>
55
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed."/>
66
<MediaTemplate EmbedCab="yes"/>
7-
<!-- Check installation prerequisites. -->
8-
<!-- C++ 2019 -->
9-
<Property Id="CPPRUNTIME2019X64" Secure="yes">
10-
<?foreach CPPRUNTIMEVERSIONPREFIX in 21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37?>
11-
<RegistrySearch Id="CPPv$(var.CPPRUNTIMEVERSIONPREFIX)x64" Type="raw" Root="HKCR" Key="Installer\Dependencies\VC,redist.x64,amd64,14.$(var.CPPRUNTIMEVERSIONPREFIX),bundle"/>
12-
<?endforeach?>
13-
</Property>
14-
<Condition Message="Microsoft Visual C++ 2019 (x64) Redistributable missing">REMOVE OR Installed OR CPPRUNTIME2019X64</Condition>
157
<!-- Disable change/repair in Add/Remove programs. -->
16-
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" />
8+
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" />
179
<Property Id="ARPNOMODIFY" Value="yes" Secure="yes" />
1810
<!-- Add files to the filesystem. -->
1911
<!--

0 commit comments

Comments
 (0)