diff --git a/src/Wt/Http/Request b/src/Wt/Http/Request index 670e39a..9775268 100644 --- a/src/Wt/Http/Request +++ b/src/Wt/Http/Request @@ -19,7 +19,7 @@ namespace Wt { class WResource; - +class WSslInfo; class WebRequest; class WebSession; @@ -372,6 +372,33 @@ public: */ ByteRangeSpecifier getRanges(::int64_t filesize) const; + /*! \brief Returns information on the SSL client certificate or \c 0 + * if no authentication took place. + * + * This function will return \c 0 if no verification took place, %Wt + * was compiled without SSL support, or the web server was + * configured without client SSL certificates. + * + * This method may return a pointer to a WSslInfo object, while the + * authentication may have failed. This depends on the configuration + * of the web server. It is therefore important to always check the + * verification result with WSslInfo::clientVerificationResult(). + * + * Session-bound resources will probably not use this method, but rely on + * the validation done at the start of the session (see sslInfo() in + * WEnvironment). Static resources on the other hand don't have an + * associated session, so using this method you can perform client + * authentication verification. + * + * The object returned is owned by Request and will be deleted + * when the Request object is destroyed. + * + * \sa WEnvironment::sslInfo() + */ + WSslInfo *sslInfo() const { + return sslInfo_; + } + static ByteRangeSpecifier getRanges(const std::string &header, ::int64_t filesize); @@ -387,9 +414,11 @@ private: const UploadedFileMap& files_; ResponseContinuation *continuation_; std::map cookies_; + WSslInfo *sslInfo_; Request(const WebRequest& request, ResponseContinuation *continuation); Request(const ParameterMap& parameters, const UploadedFileMap& files); + ~Request(); friend class Wt::WResource; friend class Wt::WebSession; diff --git a/src/Wt/Http/Request.C b/src/Wt/Http/Request.C index 25e7b49..89bd5a3 100644 --- a/src/Wt/Http/Request.C +++ b/src/Wt/Http/Request.C @@ -319,20 +319,29 @@ Request::Request(const WebRequest& request, ResponseContinuation *continuation) : request_(&request), parameters_(request.getParameterMap()), files_(request.uploadedFiles()), - continuation_(continuation) + continuation_(continuation), + sslInfo_(request.sslInfo()) { } Request::Request(const ParameterMap& parameters, const UploadedFileMap& files) : request_(0), parameters_(parameters), files_(files), - continuation_(0) + continuation_(0), + sslInfo_(0) { std::string cookie = headerValue("Cookie"); if (!cookie.empty()) parseCookies(cookie, cookies_); } +Request::~Request() +{ +#ifdef WT_WITH_SSL + delete sslInfo_; +#endif +} + #ifndef WT_TARGET_JAVA void Request::parseFormUrlEncoded(const std::string& s, ParameterMap& parameters) diff --git a/src/Wt/WEnvironment b/src/Wt/WEnvironment index 9af0ae7..2d06dda 100644 --- a/src/Wt/WEnvironment +++ b/src/Wt/WEnvironment @@ -611,6 +611,8 @@ public: * * The object returned is owned by WEnvironment and will be deleted * when WEnvironment is destroyed (= at the end of the session). + * + * \sa Wt::Http::Request::sslInfo() */ WSslInfo *sslInfo() const { return sslInfo_;