Throwing special exception MediaBadCAException in case of SSL certificate validation...
authorJosef Reidinger <jreidinger@suse.cz>
Fri, 21 Mar 2008 12:20:16 +0000 (12:20 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Fri, 21 Mar 2008 12:20:16 +0000 (12:20 +0000)
zypp/media/MediaCurl.cc
zypp/media/MediaException.cc
zypp/media/MediaException.h

index 213d544..27663c8 100644 (file)
@@ -1082,6 +1082,8 @@ bool MediaCurl::doGetDoesFileExist( const Pathname & filename ) const
         err  = "Timeout reached";
         ZYPP_THROW(MediaTimeoutException(url));
         break;
+      case CURLE_SSL_CACERT:
+        ZYPP_THROW(MediaBadCAException(url,_curlError));
       case CURLE_SSL_PEER_CERTIFICATE:
       default:
         err = curl_easy_strerror(ok);
index 2dceb5f..816c9af 100644 (file)
@@ -207,6 +207,13 @@ namespace zypp
         return str << form(_("Timeout exceed when access '%s'."), _url.c_str()) << endl;
       return str << _msg << endl;
     }
+
+    std::ostream & MediaBadCAException::dumpOn( std::ostream & str ) const
+    {
+      if (_msg.empty())
+        return str << form(_(" SSL certificate problem, verify that the CA cert is OK for '%s'."), _url.c_str()) << endl;
+      return str << _msg << endl;
+    }
   /////////////////////////////////////////////////////////////////
   } // namespace media
 } // namespace zypp
index 1b97249..f3e2070 100644 (file)
@@ -485,6 +485,19 @@ namespace zypp
       std::string _msg;
     };
 
+    class MediaBadCAException : public MediaException
+    {
+    public:
+      MediaBadCAException(const Url & url_r, const std::string & msg = "Invalid CA")
+      : MediaException(msg)
+      , _url(url_r.asString()), _msg(msg)
+      {}
+      virtual ~MediaBadCAException() throw() {};
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
   /////////////////////////////////////////////////////////////////
   } // namespace media
 } // namespace zypp