summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2009-11-06 11:04:00 +0100
committerJason Gerard DeRose <jderose@redhat.com>2009-11-06 16:05:36 -0700
commit63c6c12d69a4326e9cc76dd02625ee15252856d5 (patch)
treefc7292c4263859376097902a043d1219b2715c2f /ipalib
parent566a3cb9722233b4ee92ef55db5a04dc0f26ee9d (diff)
downloadfreeipa-63c6c12d69a4326e9cc76dd02625ee15252856d5.tar.gz
freeipa-63c6c12d69a4326e9cc76dd02625ee15252856d5.tar.xz
freeipa-63c6c12d69a4326e9cc76dd02625ee15252856d5.zip
Use File parameter for CSR in cert_request command plugin.
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/cert.py41
1 files changed, 12 insertions, 29 deletions
diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py
index 0416730f8..48ceaa6d7 100644
--- a/ipalib/plugins/cert.py
+++ b/ipalib/plugins/cert.py
@@ -26,7 +26,7 @@ from ipalib import api, SkipPluginModule
if api.env.enable_ra is not True:
# In this case, abort loading this plugin module...
raise SkipPluginModule(reason='env.enable_ra is not True')
-from ipalib import Command, Str, Int, Bytes, Flag
+from ipalib import Command, Str, Int, Bytes, Flag, File
from ipalib import errors
from ipalib.plugins.virtual import *
from ipalib.plugins.service import split_principal
@@ -83,7 +83,11 @@ class cert_request(VirtualCommand):
Submit a certificate signing request.
"""
- takes_args = (Str('csr', validate_csr),)
+ takes_args = (
+ File('csr', validate_csr,
+ cli_name='csr_file',
+ ),
+ )
operation="request certificate"
takes_options = (
@@ -110,6 +114,12 @@ class cert_request(VirtualCommand):
del kw['add']
service = None
+ # We just want the CSR bits, make sure there is nothing else
+ s = csr.find("-----BEGIN NEW CERTIFICATE REQUEST-----")
+ e = csr.find("-----END NEW CERTIFICATE REQUEST-----")
+ if s >= 0:
+ csr = csr[s+40:e]
+
# Can this user request certs?
self.check_access()
@@ -157,33 +167,6 @@ class cert_request(VirtualCommand):
else:
textui.print_plain('Failed to submit a certificate request.')
- def run(self, *args, **options):
- """
- Dispatch to forward() and execute() to do work locally and on the
- server.
- """
- if self.env.in_server:
- return self.execute(*args, **options)
-
- # Client-side code
- csr = args[0]
- if csr[:7] == "file://":
- file = csr[7:]
- try:
- f = open(file, "r")
- csr = f.readlines()
- f.close()
- except IOError, err:
- raise errors.ValidationError(name='csr', error=err[1])
- csr = "".join(csr)
- # We just want the CSR bits, make sure there is nothing else
- s = csr.find("-----BEGIN NEW CERTIFICATE REQUEST-----")
- e = csr.find("-----END NEW CERTIFICATE REQUEST-----")
- if s >= 0:
- csr = csr[s+40:e]
- csr = csr.decode('UTF-8')
- return self.forward(csr, **options)
-
api.register(cert_request)