From: Josef Reidinger Date: Fri, 21 Mar 2008 12:20:16 +0000 (+0000) Subject: Throwing special exception MediaBadCAException in case of SSL certificate validation... X-Git-Tag: BASE-SuSE-Linux-11_0-Branch~396 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28a7995e916389bf9bc0e482b33cbfef8e2cf59f;p=platform%2Fupstream%2Flibzypp.git Throwing special exception MediaBadCAException in case of SSL certificate validation failure.(bnc #223512) --- diff --git a/zypp/media/MediaCurl.cc b/zypp/media/MediaCurl.cc index 213d544..27663c8 100644 --- a/zypp/media/MediaCurl.cc +++ b/zypp/media/MediaCurl.cc @@ -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); diff --git a/zypp/media/MediaException.cc b/zypp/media/MediaException.cc index 2dceb5f..816c9af 100644 --- a/zypp/media/MediaException.cc +++ b/zypp/media/MediaException.cc @@ -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 diff --git a/zypp/media/MediaException.h b/zypp/media/MediaException.h index 1b97249..f3e2070 100644 --- a/zypp/media/MediaException.h +++ b/zypp/media/MediaException.h @@ -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