~jimbaker/pyjuju/debug-relation-hook-context

« back to all changes in this revision

Viewing changes to juju/providers/ec2/files.py

[r=hazmat][f=781949] Make it so EC2 provider can check SSL cert validity

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
from twisted.internet.defer import fail
15
15
from twisted.web.error import Error
 
16
from OpenSSL.SSL import Error as SSLError
16
17
from txaws.s3.client import URLContext
17
18
 
18
 
from juju.errors import FileNotFound
 
19
from juju.errors import FileNotFound, SSLVerificationError
19
20
 
20
21
_FILENOTFOUND_CODES = ("NoSuchKey", "NoSuchBucket")
21
22
 
83
84
 
84
85
        def on_no_file(failure):
85
86
            # Trap file not found errors and wrap them in an application error.
86
 
            failure.trap(Error)
 
87
            failure.trap(Error, SSLError)
 
88
            if type(failure.value) == SSLError:
 
89
                return fail(SSLVerificationError(failure.value))
87
90
            if str(failure.value.status) != "404":
88
91
                return failure
89
92
            return fail(FileNotFound("s3://%s/%s" % (self._bucket, name)))