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

Show passphrase field in CredentialDialog for cc type #2006

Merged
merged 3 commits into from
Mar 3, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [8.0.2] - unreleased

### Added
- Show passphrase field in credential dialog for cc type [#2006](https://github.com/greenbone/gsa/pull/2006)
- Display error details at report details page [#1862](https://github.com/greenbone/gsa/pull/1862)
- Added warnings to content composer if reportResultThreshold is exceeded [#1852](https://github.com/greenbone/gsa/pull/1852)
- Added parseText to model.js to parse single space summary [#1829](https://github.com/greenbone/gsa/pull/1829)
Expand Down
4 changes: 3 additions & 1 deletion gsa/src/web/pages/credentials/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ class CredentialsDialog extends React.Component {
</FormGroup>
)}

{state.credential_type === USERNAME_SSH_KEY_CREDENTIAL_TYPE && (
{(state.credential_type === USERNAME_SSH_KEY_CREDENTIAL_TYPE ||
state.credential_type ===
CLIENT_CERTIFICATE_CREDENTIAL_TYPE) && (
<FormGroup title={_('Passphrase')}>
<Divider>
{is_edit && (
Expand Down
18 changes: 14 additions & 4 deletions gsad/src/gsad_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,7 @@ create_credential_gmp (gvm_connection_t *connection, credentials_t *credentials,
else if (str_equal (type, "cc"))
{
CHECK_VARIABLE_INVALID (certificate, "Create Credential");
CHECK_VARIABLE_INVALID (passphrase, "Create Credential");
CHECK_VARIABLE_INVALID (private_key, "Create Credential");

ret = gmpf (
Expand All @@ -3636,11 +3637,13 @@ create_credential_gmp (gvm_connection_t *connection, credentials_t *credentials,
"<certificate>%s</certificate>"
"<key>"
"<private>%s</private>"
"<phrase>%s</phrase>"
"</key>"
"<allow_insecure>%s</allow_insecure>"
"</create_credential>",
name, comment ? comment : "", type, certificate ? certificate : "",
private_key ? private_key : "", allow_insecure);
private_key ? private_key : "", passphrase ? passphrase : "",
allow_insecure);
}
else if (str_equal (type, "snmp"))
{
Expand Down Expand Up @@ -4129,7 +4132,7 @@ char *
save_credential_gmp (gvm_connection_t *connection, credentials_t *credentials,
params_t *params, cmd_response_data_t *response_data)
{
int ret, change_password, change_ssh_passphrase;
int ret, change_password, change_ssh_passphrase, change_passphrase;
int change_community, change_privacy_password;
gchar *html, *response;
const char *credential_id, *public_key;
Expand Down Expand Up @@ -4249,18 +4252,25 @@ save_credential_gmp (gvm_connection_t *connection, credentials_t *credentials,
}
else if (str_equal (type, "cc"))
{
change_passphrase = params_value_bool (params, "change_passphrase");

if ((certificate && strcmp (certificate, "")))
{
xml_string_append (command, "<certificate>%s</certificate>",
certificate);
}

if ((private_key && strcmp (private_key, "")))
if ((private_key && strcmp (private_key, "")) || change_passphrase)
{
xml_string_append (command, "<key>");
xml_string_append (command, "<private>%s</private>", private_key);
if (change_passphrase)
xml_string_append (command, "<phrase>%s</phrase>", passphrase);
if (private_key)
xml_string_append (command, "<private>%s</private>", private_key);
xml_string_append (command, "</key>");
}


}
else if (str_equal (type, "usk"))
{
Expand Down