mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-21 01:41:25 -07:00
[PR #9970/42a161ab backport][stable-10] param pkcs12_alias and cert_alias to be optional in java_cert module (#10001)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
import-galaxy / Test to import built collection artifact with Galaxy importer (push) Has been cancelled
Verify REUSE / check (push) Has been cancelled
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
import-galaxy / Test to import built collection artifact with Galaxy importer (push) Has been cancelled
Verify REUSE / check (push) Has been cancelled
param pkcs12_alias and cert_alias to be optional in java_cert module (#9970)
* changed pkcs12_alias and cert_alias to be optional when importing pkcs12 certificate in keystore
* Add changelog fragment
* Update changelogs/fragments/9970-pkcs12_alias_cert_alias_optional.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update changelogs/fragments/9970-pkcs12_alias_cert_alias_optional.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 42a161abf5
)
Co-authored-by: Emanuele Bernardi <e.berna@gmail.com>
This commit is contained in:
parent
1d7aad9b46
commit
138740127a
3 changed files with 29 additions and 7 deletions
|
@ -315,12 +315,13 @@ def _export_public_cert_from_pkcs12(module, executable, pkcs_file, alias, passwo
|
|||
"-noprompt",
|
||||
"-keystore",
|
||||
pkcs_file,
|
||||
"-alias",
|
||||
alias,
|
||||
"-storetype",
|
||||
"pkcs12",
|
||||
"-rfc"
|
||||
]
|
||||
# Append optional alias
|
||||
if alias:
|
||||
export_cmd.extend(["-alias", alias])
|
||||
(export_rc, export_stdout, export_err) = module.run_command(export_cmd, data=password, check_rc=False)
|
||||
|
||||
if export_rc != 0:
|
||||
|
@ -393,6 +394,10 @@ def import_pkcs12_path(module, executable, pkcs12_path, pkcs12_pass, pkcs12_alia
|
|||
keystore_path, keystore_pass, keystore_alias, keystore_type):
|
||||
''' Import pkcs12 from path into keystore located on
|
||||
keystore_path as alias '''
|
||||
optional_aliases = {
|
||||
"-destalias": keystore_alias,
|
||||
"-srcalias": pkcs12_alias
|
||||
}
|
||||
import_cmd = [
|
||||
executable,
|
||||
"-importkeystore",
|
||||
|
@ -401,13 +406,14 @@ def import_pkcs12_path(module, executable, pkcs12_path, pkcs12_pass, pkcs12_alia
|
|||
"pkcs12",
|
||||
"-srckeystore",
|
||||
pkcs12_path,
|
||||
"-srcalias",
|
||||
pkcs12_alias,
|
||||
"-destkeystore",
|
||||
keystore_path,
|
||||
"-destalias",
|
||||
keystore_alias
|
||||
]
|
||||
# Append optional aliases
|
||||
for flag, value in optional_aliases.items():
|
||||
if value:
|
||||
import_cmd.extend([flag, value])
|
||||
|
||||
import_cmd += _get_keystore_type_keytool_parameters(keystore_type)
|
||||
|
||||
secret_data = "%s\n%s" % (keystore_pass, pkcs12_pass)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue