Repository navigation
Closed
Labels
bugbroken, incorrect, or confusing behaviorseverity-low4th level, cosemtic problems, work around exists
Milestone
Description
Description of Issue
The documentation for /keys POST method states that:
Accepts all the same parameters as the
key.gen_accept.
However, it seems to be impossible to specify a keysize larger than 2048.
Here's a snippet I'm using:
import requests
user = 'someuser'
password = 'somepasswd'
api_uri = 'https://my_api.tld'
api = requests.Session()
auth = api.post('{0}/login'.format(api_uri),
headers = {'Accept': 'application/x-yaml'},
data = {'username': user,
'password': password,
'eauth': 'ldap'})
# ...
keypair = api.post('{0}/keys'.format(api_uri),
data = {'mid': 'testminion',
'username': user,
'password': password,
# 'keysize': 4096, # "A"
'keysize': '4096', # "B"
'eauth': 'ldap'})
with open('/tmp/keys.tar', 'wb') as fh:
fh.write(keypair.content)
# ...Now, /tmp/keys.tar is indeed a tarball that contains a private and public key with method "B" - but it is always only 2048 bits (checked with openssl rsa -text -noout -in minion.pem).
With method "A", though, not only is a keypair not created, but the API throws the following exception:
[22/Mar/2020:02:21:01] HTTP
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/cherrypy/_cprequest.py", line 670, in respond
response.body = self.handler()
File "/usr/lib/python3.6/site-packages/cherrypy/lib/encoding.py", line 217, in __call__
self.body = self.oldhandler(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/cherrypy/_cpdispatch.py", line 60, in __call__
return self.callable(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/salt/netapi/rest_cherrypy/app.py", line 1717, in POST
pub_key = ret.get('pub', '')
AttributeError: 'str' object has no attribute 'get'returning the following with a 500:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<title>500 Internal Server Error</title>
<style type="text/css">
#powered_by {
margin-top: 20px;
border-top: 2px solid black;
font-style: italic;
}
#traceback {
color: red;
}
</style>
</head>
<body>
<h2>500 Internal Server Error</h2>
<p>The server encountered an unexpected condition which prevented it from fulfilling the request.</p>
<pre id="traceback"></pre>
<div id="powered_by">
<span>
Powered by <a href="http://www.cherrypy.org">CherryPy 5.6.0</a>
</span>
</div>
</body>
</html>Setup
N/A
Steps to Reproduce Issue
See above
Versions Report
Salt Version:
Salt: 3000
Dependency Versions:
cffi: 1.9.1
cherrypy: unknown
dateutil: Not Installed
docker-py: Not Installed
gitdb: 2.0.5
gitpython: 2.1.11
Jinja2: 2.10.3
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: 1.3.12
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Aug 7 2019, 17:28:10)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 15.3.0
smmap: 2.0.5
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4
System Versions:
dist: centos 7.7.1908 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1062.12.1.el7.x86_64
system: Linux
version: CentOS Linux 7.7.1908 CoreAnd, in my attempts to be clever, I tried:
# (...)
resp = api.post('{0}/'.format(api_uri),
data = {'client': 'local',
'fun': 'cmd.run',
'arg': ['testminion'],
'kwarg': {'keysize': '4096'}})
# (...)(EDIT: Yes, I just realized this makes no sense; I was tired. Whoops!)
but this only returns another 500 with:
{"status": 500, "return": "An unexpected error occurred"}Metadata
Metadata
Assignees
Labels
bugbroken, incorrect, or confusing behaviorseverity-low4th level, cosemtic problems, work around exists
Activity
johnnybubonic commentedon Mar 22, 2020
additionally, more of a feature request than an issue, but the files in the tarball have a timestamp of UNIX Epoch. they should probably match time of request or time of generation.I have a PR in for this since it was a pretty trivial change and required no knowledge of Salt internals.
Improve salt rest_cherrypy gen_keys tarball
Ch3LL commentedon Mar 23, 2020
thanks for the pr!
Coerce keysize to int in wheel key.gen
Fix 5 root causes surfaced by CI run 31975776712 on PR saltstack#70063
Coerce keysize to int in wheel key.gen