Skip to content

rgw: beast ssl certs config through config-key - #33287

Merged
liewegas merged 10 commits into
ceph:masterfrom
yehudasa:wip-rgw-ssl-conf
Mar 4, 2020
Merged

liewegas merged 10 commits into
ceph:masterfrom
yehudasa:wip-rgw-ssl-conf

Conversation

@yehudasa

Copy link
Copy Markdown
Member

Implements: https://tracker.ceph.com/issues/44128

For example:

radosgw --rgw-frontends= \
  "beast ssl_port=443 \
  ssl_certificate=config://rgw/cert/domain.crt \
  ssl_private_key=config://rgw/cert/domain.key"

Signed-off-by: Yehuda Sadeh [email protected]

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frontend code looks great, but it feels like overkill to add two new services for this. can we just call into the rados service directly, until we have a need for more abstraction?

Comment thread doc/radosgw/frontends.rst Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we document the security considerations here? aren't these keys being sent over the wire in cleartext unless messenger encryption is on? how can we make it impossible for users to get this wrong?

a link to some docs about setting up the keys would be helpful too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can require that if this is set then client_modes and possibly mon_client_modes are set to secure only?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should probably enforce secure mode all on communication to/from mon and mgr. But that's maybe a different discussion. See #33288 also.

@yehudasa

Copy link
Copy Markdown
Member Author

@cbodley overkill? maybe. But I think it's vital that we hide the specific rados implementation details if possible.

@liewegas

Copy link
Copy Markdown
Member

Would it make sense to somehow make rgw default to pulling the cert from rgw/$realm/... or rgw/$realm/$zone/...? If I'm reading this right the key name needs to be set midway in the rgw_frontends config option, which is a bit awkward. If not present there, it could fall back to looking in the rgw_data dir with a default filename instead.

@yehudasa

Copy link
Copy Markdown
Member Author

@liewegas it never looks unless the fronend config is set, so that would require adding new defaults to the frontend, and also have it behave differently. There are no default filenames. I'm not against doing that, but need to make sure that would make sense.

@cbodley

cbodley commented Feb 18, 2020

Copy link
Copy Markdown
Contributor

But I think it's vital that we hide the specific rados implementation details if possible.

can't the frontend just check whether a rados service exists, and use that to call mon_command()?

i don't think we need a generic interface, especially as part of the service framework, until we have a second implementation. this could just be a helper function like:

int rgw_config_key_get(RGWSI_RADOS *rados, const string& key, bufferlist *result);

@yehudasa

Copy link
Copy Markdown
Member Author

@cbodley why should the frontend know about rados? The servification was done in order to make things abstracted from the get go, so that we hide all that logic from the upper layers.

@yehudasa

Copy link
Copy Markdown
Member Author

@liewegas added the option to have set default configurables for rgw frontends, and by default it will have for beast frontend ssl_certificate=config://rgw/cert/$realm/$zone.crt ssl_private_key=config://rgw/cert/$realm/$zone.key

"{"
"\"prefix\": \"config-key get\", "
"\"key\": \"" + key + "\""
"}";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it. For completeness sake, should be make this also able to get stuff out of the config database, not just the config-key database?

Maybe we can't call it ConfigKey in that case.

Maybe it needs to be MonConfig::get and MonConfig::getkey or something(or just GSWSI_Config::)? If you look into the cephadm rgw code, they set the realm and zone using config set (https://github.com/ceph/ceph/blob/master/src/pybind/mgr/cephadm/module.py#L2089-L2100). So we need to plumb RGW to also check for not just config-key get but also config get.

This will take the who into account too and not have to worry about different keys for different RGW instances.

Just a thought

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, looking closer, can we just access the config get from config-key using key:
config/client.rgw.<realm>.<zone> but it's the processing the scope of the config which is, I'm assuming, already handled by the mon config, ie, the who. For example, do I need to check config/client/option or config/client.rgw,realm/option or config/client.rgw.realm.zone etc

That'll be alot more requests to the mon asking about existence of options then just a single call to mon config get

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewoliver I'm not sure I quite follow you, but note that config get won't apply the defaults on rgw_frontends

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm probably confusing things. The problem is outside of rgw_frontends. The current version of the rgw code in cephadm sets the rgw_realm and rgw_zone options via config set. But not sure RGW currently can or does get these values from the config get. So am guessing will always default to default for both.

I know that is out of scope of what your trying to do here. But was raising the suggestion of extending the plumbing you've done to include config get in the hopes that it means we don't need to dump the realm and zone in the ceph.conf in the container to really get it to work.

NOTE: I'm assuming here that in fact RGW currently isn't talking to config get as I can't see any mon_commands that do that. And pretty sure the ConfigProxy object doesn't.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can configure these params (realm, zonegroup, zone) via the ceph config commands.

@cbodley

cbodley commented Feb 19, 2020

Copy link
Copy Markdown
Contributor

The servification was done in order to make things abstracted from the get go, so that we hide all that logic from the upper layers.

ok. i'm still uncomfortable with the proliferation of services and the amount of boilerplate it takes to do simple things. i'd really like to revisit services as part of the zipper project, to see which parts can be taken over by the rados store, and which abstractions still make sense outside

more than anything, i just want the development of new features to be easy

@cbodley

cbodley commented Feb 19, 2020

Copy link
Copy Markdown
Contributor

by default it will have for beast frontend ssl_certificate=config://rgw/cert/$realm/$zone.crt ssl_private_key=config://rgw/cert/$realm/$zone.key

now that these are the defaults, i'd really like to avoid trying to fetch these keys from the monitor unless the frontend configuration actually requests an ssl port

matthewoliver added a commit to matthewoliver/ceph-iscsi that referenced this pull request Feb 20, 2020
DO NOT MERGE, STILL A WIP.

I'm looking at attempting to add iscsi to cephadm, but frankly having
to place the crt and key inside the container makes things a little
harder. While working on adding RGW SSL support to cephadm sage et al,
suggested we should use the mon config-key store the certs[0][1].

So thought why not fo the same here. This will mean when setting up
service in cephadm, an op can either place the certs:

  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.crt -i <file>
  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.key -i <file>

Or if given the files via cephadm we can place them on their behalf.

[0]- ceph/ceph#32951
[1]- ceph/ceph#33287

Signed-off-by: Matthew Oliver <[email protected]>
@yehudasa

Copy link
Copy Markdown
Member Author

ok. i'm still uncomfortable with the proliferation of services and the amount of boilerplate it takes to do simple things. i'd really like to revisit services as part of the zipper project, to see which parts can be taken over by the rados store, and which abstractions still make sense outside

more than anything, i just want the development of new features to be easy

I understand that. I do think that when dealing with rados internal apis we should avoid introducing new direct calls into them. Keeping everything in under svc/ makes it easier to see the interdependencies and helps avoiding creating entanglements that will be hard to break later. Some stuff could surely go elsewhere, but I felt that since this is an a standalone ceph service with a unique purpose it deserves its own module.

@yehudasa

Copy link
Copy Markdown
Member Author

by default it will have for beast frontend ssl_certificate=config://rgw/cert/$realm/$zone.crt ssl_private_key=config://rgw/cert/$realm/$zone.key

now that these are the defaults, i'd really like to avoid trying to fetch these keys from the monitor unless the frontend configuration actually requests an ssl port

@cbodley 6f48e96

@liewegas liewegas added this to the octopus milestone Feb 24, 2020
matthewoliver added a commit to matthewoliver/ceph-iscsi that referenced this pull request Feb 26, 2020
DO NOT MERGE, STILL A WIP.

I'm looking at attempting to add iscsi to cephadm, but frankly having
to place the crt and key inside the container makes things a little
harder. While working on adding RGW SSL support to cephadm sage et al,
suggested we should use the mon config-key store the certs[0][1].

So thought why not fo the same here. This will mean when setting up
service in cephadm, an op can either place the certs:

  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.crt -i <file>
  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.key -i <file>

Or if given the files via cephadm we can place them on their behalf.

[0]- ceph/ceph#32951
[1]- ceph/ceph#33287

Signed-off-by: Matthew Oliver <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
Fixes: https://tracker.ceph.com/issues/44128

For example:

radosgw --rgw-frontends= \
  "beast ssl_port=443 \
  ssl_certificate=config://rgw/cert/domain.crt \
  ssl_private_key=config://rgw/cert/domain.key"

Signed-off-by: Yehuda Sadeh <[email protected]>
Also don't exit immediately if can't init ssl cert, only if cert is actually
needed (if ssl_port/ssl_endpoint is configured).

Signed-off-by: Yehuda Sadeh <[email protected]>
Add the following variables:
$realm, $realm_id, $zonegroup, $zonegroup_id, $zone, $zone_id

Variables can also be passed in with curly braces, e.g., ${realm}

Signed-off-by: Yehuda Sadeh <[email protected]>
Allow setting default configuration per frontend config option. This allows
having defaults for part of the frontend config options and set others.

Signed-off-by: Yehuda Sadeh <[email protected]>
So that central config could be used

Signed-off-by: Yehuda Sadeh <[email protected]>
@liewegas

liewegas commented Mar 3, 2020

Copy link
Copy Markdown
Member

retest this please

@liewegas
liewegas requested a review from cbodley March 3, 2020 15:48
@cbodley

cbodley commented Mar 3, 2020

Copy link
Copy Markdown
Contributor

do we have a way to guarantee that the keys are fetched over an encrypted connection?

@liewegas

liewegas commented Mar 3, 2020

Copy link
Copy Markdown
Member

They are by default. But rgw could also verify that the ms_mon_client_mode is secure. It defaults to allow secure or crc, but for rgw we could (1) make it default to secure and (2) this code path could verify it is set that way.

I'm not 100% sold on (2), though--usually we don't prevent users from doing weird things if that's what the config options say to do.

@cbodley cbodley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: document security considerations, warn on insecure mon connection

@liewegas
liewegas merged commit 966c050 into ceph:master Mar 4, 2020
Comment thread src/rgw/rgw_main.cc
// claim the reference and release it after subsequent destructors have fired
auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_DAEMON,
flags, "rgw_data", false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yehudasa a regression was reported in https://tracker.ceph.com/issues/44661 because we're now calling global_init() before this happens below:

      // If civetweb or beast is configured as a frontend, prevent global_init() from
      // dropping permissions by setting the appropriate flag.
      flags |= CINIT_FLAG_DEFER_DROP_PRIVILEGES;

our teuthology suite uses these privileged ports and hasn't seen any failures here, so I'm not sure where the gap is

matthewoliver added a commit to matthewoliver/ceph-iscsi that referenced this pull request Apr 20, 2020
I'm looking at attempting to add iscsi to cephadm, but frankly having
to place the crt and key inside the container makes things a little
harder. While working on adding RGW SSL support to cephadm sage et al,
suggested we should use the mon config-key store the certs[0][1].

So thought why not fo the same here. This will mean when setting up
service in cephadm, an op can either place the certs:

  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.crt -i <file>
  ceph config-key put 'iscsi/<client-name>/iscsi-gateway.key -i <file>

Or if given the files via cephadm we can place them on their behalf.

[0]- ceph/ceph#32951
[1]- ceph/ceph#33287

Signed-off-by: Matthew Oliver <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants