Bug 6843 - problems with empty string for ssl_cert, ssl_key
: problems with empty string for ssl_cert, ssl_key
Status: RESOLVED FIXINSOURCE
Product: pkg
api-python
: unspecified
: ANY/Generic All
: P4 normal (vote)
: ---
Assigned To: Shawn Walker
: pkg/api-python watcher
:
:
:
: 5871
:
  Show dependency treegraph
 
Reported: 2009-02-23 12:13 UTC by Tom Mueller
Modified: 2009-03-09 14:27 UTC (History)
0 users (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description Tom Mueller 2009-02-23 12:13:08 UTC
There are several problems relating to the ssl_cert and ssl_key values in the
cfg_cache file, the Image.set_authority API, and the misc.versioned_urlopen
method.

1. Once the ssl_cert and ssl_key values for an authority are set to something
other than None, there is no way to change them back to None. Calling 

img.set_authority(authname, ssl_cert=None)

doesn't work because the None value is used to mean that no information for
that argument is being passed in. 

img.set_authority(authname, ssl_cert="")

doesn't work either because the set_authority method does an "if ssl_cert"
before setting the value, and Python evaluates the empty string as false in
that context. 

2. Even if ssl_cert="" worked, the value in the cfg_cache needs to be set to
None, not the empty string.  If it is set to the empty string, then the check
in misc.versioned_urlopen will treat the URL as and HTTPS URL with client
authentication even though it shouldn't. 

Suggested fix:

1) When pkg(5) reads the cfg_cache file, and empty string for ssl_cert or
ssl_key should be treated the same as None.

2) When image.set_authority is passed an empty string for the ssl_cert or
ssl_key, it should write None to the cfg_cache file. 

3) When pkg.misc.versioned_urlopen determines whether the connection is SSL or
non-SSL, it should look at the scheme of the URL in addition to looking at the
values for ssl_cert and ssl_key.
Comment 1 Tom Mueller 2009-02-23 12:15:20 UTC
After implementing this fix, it should be possible to change the origin URL for
an authority on the command line back to an HTTP URL by doing the following:

pkg set-authority -O http://someurl/ -k "" -c "" authname

This fix should add unit test cases that verify this.
Comment 2 Shawn Walker 2009-02-23 12:38:55 UTC
Taking as this is directly related to the authority API work.
Comment 3 Shawn Walker 2009-03-09 14:27:25 UTC
Fxied in changeset 926 / 6ee411c9026af426a657cb1f5e4b73c14c2e1112.