![]() |
Home | Documentation |
The HTTP-DA plugin
updated Mon Apr 22 2024 by Robert van Engelen
|
The upgraded HTTP digest authentication plugin for gSOAP adds support for the RFC7616 draft that is backwards compatible with RFC2617. The new plugin adds SHA-256 (and SHA-512/256 when OpenSSL supports it) algorithms, including the -sess variants. To maintain backwards compatibility with RFC2617 the MD5 algorithm is still supported but not recommended.
HTTP digest authentication does not transmit the user id and password for authentication. Instead, a server negotiates credentials (username and/or password) with a client using cryptographic hashing algorithms with nonce values to prevent replay attacks.
By contrast, HTTP basic authentication is not safe over unencrypted channels because the password is transmitted to the server unencrypted. Therefore, this mechanism provides no confidentiality protection for the transmitted credentials. HTTPS is typically preferred over or used in conjunction with HTTP basic authentication.
To support HTTP digest authentication in favor of HTTP basic authentication, you will need to install OpenSSL and follow these steps to build your projects:
-DWITH_OPENSSL.stdsoap2.c[pp] source.plugin/httpda.c, plugin/smdevp.c, and plugin/threads.cThe plugin is MT-safe by means of internal mutex locks. Mutex ensures exclusive access and updates of the shared session store with nonces to prevent replay attacks.
HTTP basic authentication is the default authentication mechanism supported by gSOAP. You can set the basic authentication credentials at the client-side with:
or if you use a proxy object generated with saopcpp2 option -j:
HTTP basic authentication should never be used over plain HTTP, because the credentials (the ID and password) are transmitted in the clear in base64 encoded form which is easily reversible. This mechanism is safer to use over HTTPS, because the HTTP headers and body are encrypted.
This upgraded HTTP digest authentication plugin supports RFC7616 and RFC2617. RFC7616 adds SHA2 and is backwards compatible to clients that use MD5. The MD5 algorithm is not allowed in FIPS making SHA-256 or SHA-512-256 digest algorithms mandatory. The client-side of the plugin handles both RFCs automatically.
To use HTTP digest authentication with gSOAP, register the http_da plugin as follows:
or if you use a proxy object generated with saopcpp2 option -j:
To make a client-side service call you will need to create a digest store http_da_info. The store holds the digest information locally on your machine to manage repeated authentication challenges from all servers you connect to. Use http_da_save() to add credentials to the store and release the store with http_da_release() when you no longer need the credentials.
The http_da_info store is intended for one thread to issue a sequence of calls that are all authenticated without requiring (re)negotiation. You should not share the http_da_info store with multiple threads, unless you use mutex locks.
Here is an example:
Again, if you use a proxy object then replace the soap_call_ns__method with the proxy method invocation, as was shown earlier.
The <authrealm> string is the protected realm of the server that requires authorization. This string can be obtained with the soap.authrealm string after an unsuccessful non-authenticated call so you can use it to save credentials to the digest store:
Before a second call is made to the same endpoint that requires authentication, you must restore the authentication state with http_da_restore(), then use it, and finally release it with http_da_release():
For HTTP proxies requiring HTTP digest authenticaiton, use the 'proxy' functions of the plugin:
A client authenticating against a server:
A client authenticating against a proxy:
As explained in the gSOAP user guid, server-side HTTP basic authentication is enforced by simply checking the soap.userid and soap.passwd values in a service method that requires client authentication: