aboutsummaryrefslogtreecommitdiff
path: root/lib/http_negotiate.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2014-07-11 09:37:18 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-07-16 17:26:08 +0200
commit9ad282b1ae1135e7d5dd2e466ff8671c1e4ee04b (patch)
tree20fda8058835d883461c231ff5297d5c99d43718 /lib/http_negotiate.c
parent223612afa213cb013f380c9c51b8c503e858bf5c (diff)
downloadgnurl-9ad282b1ae1135e7d5dd2e466ff8671c1e4ee04b.tar.gz
gnurl-9ad282b1ae1135e7d5dd2e466ff8671c1e4ee04b.tar.bz2
gnurl-9ad282b1ae1135e7d5dd2e466ff8671c1e4ee04b.zip
Remove all traces of FBOpenSSL SPNEGO support
This is just fundamentally broken. SPNEGO (RFC4178) is a protocol which allows client and server to negotiate the underlying mechanism which will actually be used to authenticate. This is *often* Kerberos, and can also be NTLM and other things. And to complicate matters, there are various different OIDs which can be used to specify the Kerberos mechanism too. A SPNEGO exchange will identify *which* GSSAPI mechanism is being used, and will exchange GSSAPI tokens which are appropriate for that mechanism. But this SPNEGO implementation just strips the incoming SPNEGO packet and extracts the token, if any. And completely discards the information about *which* mechanism is being used. Then we *assume* it was Kerberos, and feed the token into gss_init_sec_context() with the default mechanism (GSS_S_NO_OID for the mech_type argument). Furthermore... broken as this code is, it was never even *used* for input tokens anyway, because higher layers of curl would just bail out if the server actually said anything *back* to us in the negotiation. We assume that we send a single token to the server, and it accepts it. If the server wants to continue the exchange (as is required for NTLM and for SPNEGO to do anything useful), then curl was broken anyway. So the only bit which actually did anything was the bit in Curl_output_negotiate(), which always generates an *initial* SPNEGO token saying "Hey, I support only the Kerberos mechanism and this is its token". You could have done that by manually just prefixing the Kerberos token with the appropriate bytes, if you weren't going to do any proper SPNEGO handling. There's no need for the FBOpenSSL library at all. The sane way to do SPNEGO is just to *ask* the GSSAPI library to do SPNEGO. That's what the 'mech_type' argument to gss_init_sec_context() is for. And then it should all Just Work™. That 'sane way' will be added in a subsequent patch, as will bug fixes for our failure to handle any exchange other than a single outbound token to the server which results in immediate success.
Diffstat (limited to 'lib/http_negotiate.c')
-rw-r--r--lib/http_negotiate.c106
1 files changed, 0 insertions, 106 deletions
diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c
index 53df30e09..ccd005bbb 100644
--- a/lib/http_negotiate.c
+++ b/lib/http_negotiate.c
@@ -39,19 +39,6 @@
#include "curl_memory.h"
#include "url.h"
-#ifdef HAVE_SPNEGO
-# include <spnegohelp.h>
-# ifdef USE_SSLEAY
-# ifdef USE_OPENSSL
-# include <openssl/objects.h>
-# else
-# include <objects.h>
-# endif
-# else
-# error "Can't compile SPNEGO support without OpenSSL."
-# endif
-#endif
-
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -191,53 +178,6 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy,
input_token.length = rawlen;
DEBUGASSERT(input_token.value != NULL);
-
-#ifdef HAVE_SPNEGO /* Handle SPNEGO */
- if(checkprefix("Negotiate", header)) {
- unsigned char *spnegoToken = NULL;
- size_t spnegoTokenLength = 0;
- gss_buffer_desc mechToken = GSS_C_EMPTY_BUFFER;
-
- spnegoToken = malloc(input_token.length);
- if(spnegoToken == NULL) {
- Curl_safefree(input_token.value);
- return CURLE_OUT_OF_MEMORY;
- }
- memcpy(spnegoToken, input_token.value, input_token.length);
- spnegoTokenLength = input_token.length;
-
- if(!parseSpnegoTargetToken(spnegoToken,
- spnegoTokenLength,
- NULL,
- NULL,
- (unsigned char**)&mechToken.value,
- &mechToken.length,
- NULL,
- NULL)) {
- Curl_safefree(spnegoToken);
- infof(data, "Parse SPNEGO Target Token failed\n");
- }
- else if(!mechToken.value || !mechToken.length) {
- Curl_safefree(spnegoToken);
- if(mechToken.value)
- gss_release_buffer(&discard_st, &mechToken);
- infof(data, "Parse SPNEGO Target Token succeeded (NULL token)\n");
- }
- else {
- Curl_safefree(spnegoToken);
- Curl_safefree(input_token.value);
- input_token.value = malloc(mechToken.length);
- if(input_token.value == NULL) {
- gss_release_buffer(&discard_st, &mechToken);
- return CURLE_OUT_OF_MEMORY;
- }
- memcpy(input_token.value, mechToken.value, mechToken.length);
- input_token.length = mechToken.length;
- gss_release_buffer(&discard_st, &mechToken);
- infof(data, "Parse SPNEGO Target Token succeeded\n");
- }
- }
-#endif
}
major_status = Curl_gss_init_sec_context(data,
@@ -279,52 +219,6 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
CURLcode error;
OM_uint32 discard_st;
-#ifdef HAVE_SPNEGO /* Handle SPNEGO */
- if(checkprefix("Negotiate", neg_ctx->protocol)) {
- ASN1_OBJECT *object = NULL;
- unsigned char *responseToken = NULL;
- size_t responseTokenLength = 0;
- gss_buffer_desc spnegoToken = GSS_C_EMPTY_BUFFER;
-
- responseToken = malloc(neg_ctx->output_token.length);
- if(responseToken == NULL)
- return CURLE_OUT_OF_MEMORY;
- memcpy(responseToken, neg_ctx->output_token.value,
- neg_ctx->output_token.length);
- responseTokenLength = neg_ctx->output_token.length;
-
- object = OBJ_txt2obj("1.2.840.113554.1.2.2", 1);
- if(!object) {
- Curl_safefree(responseToken);
- return CURLE_OUT_OF_MEMORY;
- }
-
- if(!makeSpnegoInitialToken(object,
- responseToken,
- responseTokenLength,
- (unsigned char**)&spnegoToken.value,
- &spnegoToken.length)) {
- Curl_safefree(responseToken);
- ASN1_OBJECT_free(object);
- infof(conn->data, "Make SPNEGO Initial Token failed\n");
- }
- else if(!spnegoToken.value || !spnegoToken.length) {
- Curl_safefree(responseToken);
- ASN1_OBJECT_free(object);
- if(spnegoToken.value)
- gss_release_buffer(&discard_st, &spnegoToken);
- infof(conn->data, "Make SPNEGO Initial Token succeeded (NULL token)\n");
- }
- else {
- Curl_safefree(responseToken);
- ASN1_OBJECT_free(object);
- gss_release_buffer(&discard_st, &neg_ctx->output_token);
- neg_ctx->output_token.value = spnegoToken.value;
- neg_ctx->output_token.length = spnegoToken.length;
- infof(conn->data, "Make SPNEGO Initial Token succeeded\n");
- }
- }
-#endif
error = Curl_base64_encode(conn->data,
neg_ctx->output_token.value,
neg_ctx->output_token.length,