From 29ec63c3813cee5fa8d8b1e9ad032a89992791eb Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 13 Sep 2011 14:25:16 -0400 Subject: Skip the cert validator if the csr we are passed in is a valid filename The validator will still fire, just after the load_files() call. Basically it will hit the validator twice. The first time it will exit because the value of csr is a filename. The second time it will run the validator against the contents of the file. ticket https://fedorahosted.org/freeipa/ticket/1777 --- ipalib/plugins/cert.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ipalib') diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py index e32004e54..aa3cf2197 100644 --- a/ipalib/plugins/cert.py +++ b/ipalib/plugins/cert.py @@ -23,6 +23,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') +import os from ipalib import Command, Str, Int, Bytes, Flag, File from ipalib import errors from ipalib import pkcs10 @@ -129,6 +130,11 @@ def validate_csr(ugettext, csr): Ensure the CSR is base64-encoded and can be decoded by our PKCS#10 parser. """ + if api.env.context == 'cli': + # If we are passed in a pointer to a valid file on the client side + # escape and let the load_files() handle things + if csr and os.path.exists(csr): + return try: request = pkcs10.load_certificate_request(csr) except TypeError, e: @@ -203,6 +209,7 @@ class cert_request(VirtualCommand): takes_args = ( File('csr', validate_csr, + label=_('CSR'), cli_name='csr_file', normalizer=normalize_csr, ), -- cgit