Skip to content

Commit 4729c98

Browse files
authored
Merge pull request ceph#62908 from clwluvw/vault-cleanup
rgw: vault code cleanup
2 parents 5601c4f + 8943568 commit 4729c98

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

qa/workunits/rgw/test_awssdkv4_sig.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# $RGW_HTTP_ENDPOINT_URL needs to be set to the endpoint of the RGW
77
#
88
# Example when ceph source is cloned into $HOME and a vstart cluster is already running with a radosgw:
9-
# $ PATH=~/ceph/build/bin/:$PATH CEPH_ROOT=~/ceph RGW_HTTP_ENDPOINT=http://localhost:8000 ~/ceph/qa/workunits/rgw/test_awssdkv4_sig.sh
9+
# $ PATH=~/ceph/build/bin/:$PATH CEPH_ROOT=~/ceph RGW_HTTP_ENDPOINT_URL=http://localhost:8000 ~/ceph/qa/workunits/rgw/test_awssdkv4_sig.sh
1010
#
1111

1212
set -x

src/rgw/rgw_crypt.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,12 @@ int rgw_s3_prepare_encrypt(req_state* s, optional_yield y,
11701170
return -EINVAL;
11711171
}
11721172
/* try to retrieve actual key */
1173-
std::string key_selector = create_random_key_selector(s->cct);
1173+
if (s->cct->_conf->rgw_crypt_s3_kms_backend == RGW_SSE_KMS_BACKEND_TESTING) {
1174+
std::string key_selector = create_random_key_selector(s->cct);
1175+
set_attr(attrs, RGW_ATTR_CRYPT_KEYSEL, key_selector);
1176+
}
11741177
set_attr(attrs, RGW_ATTR_CRYPT_MODE, "SSE-KMS");
11751178
set_attr(attrs, RGW_ATTR_CRYPT_KEYID, key_id);
1176-
set_attr(attrs, RGW_ATTR_CRYPT_KEYSEL, key_selector);
11771179
set_attr(attrs, RGW_ATTR_CRYPT_CONTEXT, cooked_context);
11781180
std::string actual_key;
11791181
res = make_actual_key_from_kms(s, attrs, y, actual_key);
@@ -1226,9 +1228,7 @@ int rgw_s3_prepare_encrypt(req_state* s, optional_yield y,
12261228
if (res != 0) {
12271229
return res;
12281230
}
1229-
std::string key_selector = create_random_key_selector(s->cct);
12301231

1231-
set_attr(attrs, RGW_ATTR_CRYPT_KEYSEL, key_selector);
12321232
set_attr(attrs, RGW_ATTR_CRYPT_CONTEXT, cooked_context);
12331233
set_attr(attrs, RGW_ATTR_CRYPT_MODE, "AES256");
12341234
set_attr(attrs, RGW_ATTR_CRYPT_KEYID, key_id);

src/rgw/rgw_kms.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,8 @@ class VaultSecretEngine: public SecretEngine {
290290
secret_req.set_send_length(postdata.length());
291291
}
292292

293-
secret_req.append_header("X-Vault-Token", vault_token);
294-
if (!vault_token.empty()){
293+
if (!vault_token.empty()) {
295294
secret_req.append_header("X-Vault-Token", vault_token);
296-
vault_token.replace(0, vault_token.length(), vault_token.length(), '\000');
297295
}
298296

299297
string vault_namespace = kctx.k_namespace();
@@ -503,6 +501,8 @@ class TransitSecretEngine: public VaultSecretEngine {
503501
int res = send_request(dpp, "POST", "/datakey/plaintext/", key_id,
504502
post_data, y, secret_bl);
505503
if (res < 0) {
504+
ldpp_dout(dpp, 0) << "ERROR: Failed to send request to Vault, res: "
505+
<< res << " response: " << string_view(secret_bl.c_str(), secret_bl.length()) << dendl;
506506
return res;
507507
}
508508

@@ -588,6 +588,8 @@ class TransitSecretEngine: public VaultSecretEngine {
588588
int res = send_request(dpp, "POST", "/decrypt/", key_id,
589589
post_data, y, secret_bl);
590590
if (res < 0) {
591+
ldpp_dout(dpp, 0) << "ERROR: Failed to send request to Vault for decrypt, res: "
592+
<< res << " response: " << string_view(secret_bl.c_str(), secret_bl.length()) << dendl;
591593
return res;
592594
}
593595

@@ -656,12 +658,11 @@ class TransitSecretEngine: public VaultSecretEngine {
656658
int res = send_request(dpp, "POST", "/keys/", key_name,
657659
post_data, y, dummy_bl);
658660
if (res < 0) {
659-
return res;
660-
}
661-
if (dummy_bl.length() != 0) {
662-
ldpp_dout(dpp, 0) << "ERROR: unexpected response from Vault making a key: "
661+
ldpp_dout(dpp, 0) << "ERROR: key creation failed by Vault, ret: "
662+
<< res << " response: "
663663
<< std::string_view(dummy_bl.c_str(), dummy_bl.length())
664664
<< dendl;
665+
return res;
665666
}
666667
return 0;
667668
}

0 commit comments

Comments
 (0)