[yast-commit] r65085 - in /trunk/transfer: agent-curl/src/CurlAgent.cc agent-curl/src/CurlAgent.h module/HTTP.ycp package/yast2-transfer.changes
Author: ug Date: Fri Jul 29 14:17:07 2011 New Revision: 65085 URL: http://svn.opensuse.org/viewcvs/yast?rev=65085&view=rev Log: added support for client certificates for HTTPS Modified: trunk/transfer/agent-curl/src/CurlAgent.cc trunk/transfer/agent-curl/src/CurlAgent.h trunk/transfer/module/HTTP.ycp trunk/transfer/package/yast2-transfer.changes Modified: trunk/transfer/agent-curl/src/CurlAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/transfer/agent-curl/src/CurlAgent.cc?rev=65085&r1=65084&r2=65085&view=diff ============================================================================== --- trunk/transfer/agent-curl/src/CurlAgent.cc (original) +++ trunk/transfer/agent-curl/src/CurlAgent.cc Fri Jul 29 14:17:07 2011 @@ -22,6 +22,8 @@ CurlAgent::CurlAgent() : SCRAgent() { easySSL_val = false; + clientKeyPath_val = NULL; + clientCertPath_val = NULL; } /** @@ -37,6 +39,30 @@ return; } +void CurlAgent::clientCertSSL( const char *path ) +{ + if( clientCertPath_val != NULL ) + free(clientCertPath_val); + if( path != NULL ) { + clientCertPath_val = new char [strlen (path) + 1]; + if( clientCertPath_val != NULL ) + strcpy( clientCertPath_val, path ); + } + return; +} + +void CurlAgent::clientKeySSL( const char *path ) +{ + if( clientKeyPath_val != NULL ) + free(clientKeyPath_val); + if( path != NULL ) { + clientKeyPath_val = new char [strlen (path) + 1]; + if( clientKeyPath_val != NULL ) + strcpy( clientKeyPath_val, path ); + } + return; +} + YCPValue CurlAgent::Get( const char *url, const char *target) { @@ -64,6 +90,10 @@ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); if( easySSL_val ) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + if( clientCertPath_val != NULL ) + curl_easy_setopt(curl, CURLOPT_SSLCERT, clientCertPath_val); + if( clientKeyPath_val != NULL ) + curl_easy_setopt(curl, CURLOPT_SSLKEY, clientKeyPath_val); res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); if ( res != 0 ) { fclose( outfile ); @@ -235,6 +265,18 @@ easySSL( (bool)(value->asBoolean()->value()) ); } } + else if (path_name == "clientKeySSL") + { + if ( !value.isNull() ) { + clientKeySSL( (const char *)(value->asString()->value().c_str()) ); + } + } + else if (path_name == "clientCertSSL") + { + if ( !value.isNull() ) { + clientCertSSL( (const char *)(value->asString()->value().c_str()) ); + } + } /* else if (path_name == "post") { Modified: trunk/transfer/agent-curl/src/CurlAgent.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/transfer/agent-curl/src/CurlAgent.h?rev=65085&r1=65084&r2=65085&view=diff ============================================================================== --- trunk/transfer/agent-curl/src/CurlAgent.h (original) +++ trunk/transfer/agent-curl/src/CurlAgent.h Fri Jul 29 14:17:07 2011 @@ -27,6 +27,8 @@ * Agent private variables */ bool easySSL_val; + char* clientKeyPath_val; + char* clientCertPath_val; public: /** @@ -76,6 +78,8 @@ // virtual YCPValue Post( const char *url, const char *post, const char *target); virtual string getMapValue ( const YCPMap map, const string key, const string defaultValue); virtual void easySSL( bool easy ); + virtual void clientCertSSL( const char *path ); + virtual void clientKeySSL( const char *path ); private: Modified: trunk/transfer/module/HTTP.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/transfer/module/HTTP.ycp?rev=65085&r1=65084&r2=65085&view=diff ============================================================================== --- trunk/transfer/module/HTTP.ycp (original) +++ trunk/transfer/module/HTTP.ycp Fri Jul 29 14:17:07 2011 @@ -58,5 +58,18 @@ return; } +global define void clientCertSSL( string cert_path ) ``{ + y2debug("setting clientCertSSL to %1",cert_path); + SCR::Execute(.curl.clientCertSSL, cert_path, $[]); + return; +} + +global define void clientKeySSL( string key_path ) ``{ + y2debug("setting clientKeySSL to %1",key_path); + SCR::Execute(.curl.clientKeySSL, key_path, $[]); + return; +} + + /* EOF */ } Modified: trunk/transfer/package/yast2-transfer.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/transfer/package/yast2-transfer.changes?rev=65085&r1=65084&r2=65085&view=diff ============================================================================== --- trunk/transfer/package/yast2-transfer.changes (original) +++ trunk/transfer/package/yast2-transfer.changes Fri Jul 29 14:17:07 2011 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Fri Jul 29 14:16:32 CEST 2011 - ug@suse.de + +- add support for client certificates for HTTPS + +------------------------------------------------------------------- Fri Oct 9 14:13:13 CEST 2009 - ug@suse.de - 2.18.1 -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
ug@svn2.opensuse.org