The File parameter (parameters.py line 1298) does not work properly unless it's provided on the command line. If the command prompts for the parameter it fails. For example if one has a file called "csr" containing a certificate signing request this works: ipa cert-request --principal=foo/vm-041.idm.lab.bos.redhat.com csr however this does not: ipa cert-request --principal=foo/vm-041.idm.lab.bos.redhat.com <csr>: csr ipa: ERROR: Base64 decoding failed: Incorrect padding The reason it fails is because the validation function is being called on the file name not the file contents: The parameter is defined like this: takes_args = ( File('csr', validate_csr, cli_name='csr_file', ), ) If csr is not provided on the command line it's prompted for and validate_csr is invoked being passed the filename entered on the command line, however validate_csr is expecting file contents. The reason why it works when passed on the command line is because of the function load_files() in cli.py which is invoked in the run method of the command which loads the file contents and runs the validation routine on the file contents. The problem occurs in prompt_interactively() in cli.py which calls the parameter like this: value = param(raw, **kw) which invokes the validation routine. But the raw value is what was read from the terminal, it's the file name. There is no mechanism to cause contents of the file to be read, so the validation routine sees the file name, not the file contents and it fails.
Maybe Jason can chime in. I just don't see anyway to support the concept of File parameters using the existing parameter mechanism without a lot of special case hacks spread through the code. The fundamental problems are that the Parameter classes are read only descriptions of what the parameter should look like but don't actually contain the parameter value. The parameter value is in the kw dict of the command and there is no way for the parameter mechanism to know if what's in the kw dict has been operated on (e.g. the file name replaced with the file contents). If that were true then the normalize and/or validate routine could be used to transform the file name into the file contents, but we can't do that because we have to set a flag indicating if the file contents have been read and there is no place to set such a flag.
Upstream ticket: https://fedorahosted.org/freeipa/ticket/1777
Fixed upstream: master: https://fedorahosted.org/freeipa/changeset/29ec63c3813cee5fa8d8b1e9ad032a89992791eb ipa-2-1: https://fedorahosted.org/freeipa/changeset/e5e17dcbeee5b4b424b45794cb93bf2856435214