Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip truststore validation #524

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
35 changes: 18 additions & 17 deletions README-PLAYBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,24 @@ The top-level structure of the file is described as follows:

### Installation

| Field | Type | Format<br/>PEM | Format<br/>JKS | Format<br/>PKCS12 | Format<br/>CAPI | Description |
|---------------------|---------|----------------|----------------|-------------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| afterInstallAction | string | *Optional* | *Optional* | *Optional* | *Optional* | Execute this command after this installation is performed (both enrollment and renewal).<br/>On *nix, this uses `/bin/sh -c '<afterInstallAction>'`.<br/>On Windows, this uses `powershell.exe '<afterInstallAction>'`. |
| backupFiles | boolean | *Optional* | *Optional* | *Optional* | n/a | When `true`, backup existing certificate files before replacing during a renewal operation.<br/>Defaults to `false`. |
| capiFriendlyName | string | n/a | n/a | n/a | *Optional* | Specifies the friendly name to be used for the installed certificate in Windows CAPI store.<br/>If not set, the certificate Common Name will be used instead.<br/>**STRONGLY RECOMMENDED** to set this field as it will be made ***Required*** in a future release |
| capiIsNonExportable | boolean | n/a | n/a | n/a | *Optional* | When `true`, private key will be flagged as 'Non-Exportable' when stored in Windows CAPI store.<br/>Defaults to `false`. |
| capiLocation | string | n/a | n/a | n/a | ***Required*** | Specifies the Windows CAPI store to place the installed certificate. Typically `"LocalMachine\My"` or `"CurrentUser\My"`.<br/>**NOTE:** If the location is contained within `"`, the backslash `\` must be properly escaped (i.e. `"LocalMachine\\My"`). |
| chainFile | string | ***Required*** | n/a | n/a | n/a | Specifies the file path and name for the chain PEM bundle (Example `/etc/ssl/certs/myChain.cer`). |
| file | string | ***Required*** | ***Required*** | ***Required*** | n/a | Specifies the file path and name for the certificate file (PEM) or PKCS#12 / JKS bundle.<br/>Example `/etc/ssl/certs/myPEMfile.cer`, `/etc/ssl/certs/myPKCS12.p12`, or `/etc/ssl/certs/myJKS.jks`. |
| format | string | ***Required*** | ***Required*** | ***Required*** | ***Required*** | Specifies the format type for the installed certificate.<br/>Valid types are `PKCS12`, `PEM`, `JKS`, and `CAPI`. |
| jksAlias | string | n/a | ***Required*** | n/a | n/a | Specifies the certificate alias value within the Java Keystore. |
| jksPassword | string | n/a | ***Required*** | n/a | n/a | Specifies the password for the Java Keystore. |
| keyFile | string | ***Required*** | n/a | n/a | n/a | Specifies the file path and name for the private key PEM file (Example `/etc/ssl/certs/myKey.key`). |
| keyPassword | string | *Optional* | n/a | n/a | n/a | Specifies the password to encrypt the private key for PEM type. If not specified, the private key will be stored in an unencrypted PEM format. |
| useLegacyP12 | boolean | n/a | n/a | *Optional* | *Optional* | Default is false. Instructs vcert to use legacy encryption (3DES-SHA1 instead of AES-256-CBC) when encoding the keystore to maintain compatibility with Windows 2016 and earlier & OpenSSL versions 1.1/1.2. This is required for CAPI installs on Windows 2016. |
| ~~location~~ | string | n/a | n/a | n/a | ***DEPRECATED*** | Use `capiLocation` instead. |
| p12Password | string | n/a | n/a | ***Required*** | n/a | Specifies the password to encrypt the PKCS12 bundle. |
| Field | Type | Format<br/>PEM | Format<br/>JKS | Format<br/>PKCS12 | Format<br/>CAPI | Description |
|-------------------------|---------|----------------|----------------|-------------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| afterInstallAction | string | *Optional* | *Optional* | *Optional* | *Optional* | Execute this command after this installation is performed (both enrollment and renewal).<br/>On *nix, this uses `/bin/sh -c '<afterInstallAction>'`.<br/>On Windows, this uses `powershell.exe '<afterInstallAction>'`. |
| backupFiles | boolean | *Optional* | *Optional* | *Optional* | n/a | When `true`, backup existing certificate files before replacing during a renewal operation.<br/>Defaults to `false`. |
| capiFriendlyName | string | n/a | n/a | n/a | *Optional* | Specifies the friendly name to be used for the installed certificate in Windows CAPI store.<br/>If not set, the certificate Common Name will be used instead.<br/>**STRONGLY RECOMMENDED** to set this field as it will be made ***Required*** in a future release |
| capiIsNonExportable | boolean | n/a | n/a | n/a | *Optional* | When `true`, private key will be flagged as 'Non-Exportable' when stored in Windows CAPI store.<br/>Defaults to `false`. |
| capiLocation | string | n/a | n/a | n/a | ***Required*** | Specifies the Windows CAPI store to place the installed certificate. Typically `"LocalMachine\My"` or `"CurrentUser\My"`.<br/>**NOTE:** If the location is contained within `"`, the backslash `\` must be properly escaped (i.e. `"LocalMachine\\My"`). |
| chainFile | string | ***Required*** | n/a | n/a | n/a | Specifies the file path and name for the chain PEM bundle (Example `/etc/ssl/certs/myChain.cer`). |
| file | string | ***Required*** | ***Required*** | ***Required*** | n/a | Specifies the file path and name for the certificate file (PEM) or PKCS#12 / JKS bundle.<br/>Example `/etc/ssl/certs/myPEMfile.cer`, `/etc/ssl/certs/myPKCS12.p12`, or `/etc/ssl/certs/myJKS.jks`. |
| format | string | ***Required*** | ***Required*** | ***Required*** | ***Required*** | Specifies the format type for the installed certificate.<br/>Valid types are `PKCS12`, `PEM`, `JKS`, and `CAPI`. |
| jksAlias | string | n/a | ***Required*** | n/a | n/a | Specifies the certificate alias value within the Java Keystore. |
| jksPassword | string | n/a | ***Required*** | n/a | n/a | Specifies the password for the Java Keystore. |
| keyFile | string | ***Required*** | n/a | n/a | n/a | Specifies the file path and name for the private key PEM file (Example `/etc/ssl/certs/myKey.key`). |
| keyPassword | string | *Optional* | n/a | n/a | n/a | Specifies the password to encrypt the private key for PEM type. If not specified, the private key will be stored in an unencrypted PEM format. |
| skipCapiStoreValidation | boolean | n/a | n/a | n/a | *Optional* | When `true`, the CAPI Trust Store name validation will be skipped. Otherwise, the CAPI Trust Store name will be validated against the list here: https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.storename?view=net-7.0 |
| useLegacyP12 | boolean | n/a | n/a | *Optional* | *Optional* | Default is false. Instructs vcert to use legacy encryption (3DES-SHA1 instead of AES-256-CBC) when encoding the keystore to maintain compatibility with Windows 2016 and earlier & OpenSSL versions 1.1/1.2. This is required for CAPI installs on Windows 2016. |
| ~~location~~ | string | n/a | n/a | n/a | ***DEPRECATED*** | Use `capiLocation` instead. |
| p12Password | string | n/a | n/a | ***Required*** | n/a | Specifies the password to encrypt the PKCS12 bundle. |

### Request

Expand Down
21 changes: 13 additions & 8 deletions pkg/playbook/app/domain/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ type Installation struct {
KeyFile string `yaml:"keyFile,omitempty"`
KeyPassword string `yaml:"keyPassword,omitempty"`
// Deprecated: Location is deprecated in favor of CAPILocation. It will be removed on a future release
Location string `yaml:"location,omitempty"`
P12Password string `yaml:"p12Password,omitempty"`
UseLegacyP12 bool `yaml:"useLegacyP12,omitempty"`
Type InstallationFormat `yaml:"format,omitempty"`
Location string `yaml:"location,omitempty"`
P12Password string `yaml:"p12Password,omitempty"`
SkipCAPIValidateStoreName bool `yaml:"skipCapiStoreValidation,omitempty"`
UseLegacyP12 bool `yaml:"useLegacyP12,omitempty"`
Type InstallationFormat `yaml:"format,omitempty"`
}

// Installations is a slice of Installation
Expand Down Expand Up @@ -129,10 +130,14 @@ func validateCAPI(installation Installation) error {
// valid store names from https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.storename?view=net-7.0
// Although it is unlikely that you'd want to install a certificate and private key in anything but "my", here for completeness
isValidStoreName := false
for _, v := range validStoreNames {
if v == strings.ToLower(segments[1]) {
isValidStoreName = true
break
if installation.SkipCAPIValidateStoreName {
isValidStoreName = true
} else {
for _, v := range validStoreNames {
if v == strings.ToLower(segments[1]) {
isValidStoreName = true
break
}
}
}

Expand Down