rpms/curl/OLPC-2 curl-7.16.4-ftp.patch, NONE, 1.1 curl-7.16.4-nsspem.patch, NONE, 1.1 .cvsignore, 1.24, 1.25 curl.spec, 1.49, 1.50 sources, 1.25, 1.26 curl-7.14.1-nousr.patch, 1.1, NONE curl-7.15.0-curl_config-version.patch, 1.1, NONE

Jesse Keating (jkeating) fedora-extras-commits at redhat.com
Wed Sep 12 17:17:07 UTC 2007


Author: jkeating

Update of /cvs/pkgs/rpms/curl/OLPC-2
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11572/OLPC-2

Modified Files:
	.cvsignore curl.spec sources 
Added Files:
	curl-7.16.4-ftp.patch curl-7.16.4-nsspem.patch 
Removed Files:
	curl-7.14.1-nousr.patch curl-7.15.0-curl_config-version.patch 
Log Message:
Import f8 srpm, branch was accidentally made from F-7.


curl-7.16.4-ftp.patch:

--- NEW FILE curl-7.16.4-ftp.patch ---
--- curl-7.16.4/lib/ftp.c.ftp	2007-07-02 00:01:19.000000000 +0200
+++ curl-7.16.4/lib/ftp.c	2007-08-10 13:24:34.000000000 +0200
@@ -2372,7 +2372,7 @@ static CURLcode ftp_state_user_resp(stru
   (void)instate; /* no use for this yet */
 
   /* some need password anyway, and others just return 2xx ignored */
-  if((ftpcode == 331 || ftpcode/100 == 2) && (ftpc->state == FTP_USER)) {
+  if((ftpcode == 331) && (ftpc->state == FTP_USER)) {
     /* 331 Password required for ...
        (the server requires to send the user's password too) */
     NBFTPSENDF(conn, "PASS %s", ftp->passwd?ftp->passwd:"");

curl-7.16.4-nsspem.patch:

--- NEW FILE curl-7.16.4-nsspem.patch ---
diff -up curl-7.16.4/configure.nsspem curl-7.16.4/configure
--- curl-7.16.4/configure.nsspem	2007-06-25 11:18:41.000000000 +0200
+++ curl-7.16.4/configure	2007-09-06 08:35:31.000000000 +0200
@@ -26760,7 +26760,7 @@ echo "$as_me: WARNING: Use --with-ssl, -
 fi
 
 
-if test X"$USE_GNUTLS$OPENSSL_ENABLED" != "X"; then
+if test X"$USE_NSS$USE_GNUTLS$OPENSSL_ENABLED" != "X"; then
 
   { echo "$as_me:$LINENO: checking CA cert bundle install path" >&5
 echo $ECHO_N "checking CA cert bundle install path... $ECHO_C" >&6; }
diff -up curl-7.16.4/configure.ac.nsspem curl-7.16.4/configure.ac
--- curl-7.16.4/configure.ac.nsspem	2007-06-12 23:39:21.000000000 +0200
+++ curl-7.16.4/configure.ac	2007-09-06 08:35:31.000000000 +0200
@@ -1468,7 +1468,7 @@ dnl ************************************
 dnl Check for the CA bundle
 dnl **********************************************************************
 
-if test X"$USE_GNUTLS$OPENSSL_ENABLED" != "X"; then
+if test X"$USE_NSS$USE_GNUTLS$OPENSSL_ENABLED" != "X"; then
 
   AC_MSG_CHECKING([CA cert bundle install path])
 
diff -up curl-7.16.4/lib/nss.c.nsspem curl-7.16.4/lib/nss.c
--- curl-7.16.4/lib/nss.c.nsspem	2007-05-25 23:56:27.000000000 +0200
+++ curl-7.16.4/lib/nss.c	2007-09-06 09:26:39.000000000 +0200
@@ -55,6 +55,7 @@
 #include <ssl.h>
 #include <sslerr.h>
 #include <secerr.h>
+#include <secmod.h>
 #include <sslproto.h>
 #include <prtypes.h>
 #include <pk11pub.h>
@@ -69,10 +70,19 @@
 #define min(a, b)   ((a) < (b) ? (a) : (b))
 #endif
 
+#define SSL_DIR "/etc/pki/nssdb"
+
+/* enough to fit the string "PEM Token #[0|1]" */
+#define SLOTSIZE 13
+
 PRFileDesc *PR_ImportTCPSocket(PRInt32 osfd);
 
 static int initialized = 0;
-static int noverify = 0;
+static int verify_done = 0;
+char * select_nickname = NULL;
+
+/* Global so our callbacks can update as appropriate */
+static int curlerr;
 
 #define HANDSHAKE_TIMEOUT 30
 
@@ -87,15 +97,25 @@ typedef struct {
   PRInt32 version; /* protocol version valid for this cipher */
 } cipher_s;
 
-/* the table itself is defined in nss_engine_init.c */
 #ifdef NSS_ENABLE_ECC
 #define ciphernum 48
 #else
 #define ciphernum 23
 #endif
 
+#define PK11_SETATTRS(x,id,v,l) \
+	do { \
+		(x)->type = (id); \
+		(x)->pValue=(v); \
+		(x)->ulValueLen = (l); \
+	} while (0)
+
+#define CERT_NewTempCertificate __CERT_NewTempCertificate
+
 enum sslversion { SSL2 = 1, SSL3 = 2, TLS = 4 };
 
+pphrase_arg_t *parg = NULL;
+
 cipher_s cipherlist[ciphernum] = {
   /* SSL2 cipher suites */
   {"rc4", SSL_EN_RC4_128_WITH_MD5, SSL2},
@@ -154,6 +174,9 @@ cipher_s cipherlist[ciphernum] = {
 #endif
 };
 
+const char* pem_library = "libnsspem.so";
+static SECMODModule* mod = NULL;
+
 static SECStatus set_ciphers(struct SessionHandle *data, PRFileDesc * model,
                              char *cipher_list)
 {
@@ -197,9 +220,7 @@ static SECStatus set_ciphers(struct Sess
     }
 
     if(found == PR_FALSE) {
-      char buf[1024];
-      snprintf(buf, 1024, "Unknown cipher in list: %s", cipher);
-      failf(data, buf);
+      failf(data, "Unknown cipher in list: %s", cipher);
       return SECFailure;
     }
 
@@ -220,27 +241,240 @@ static SECStatus set_ciphers(struct Sess
   return SECSuccess;
 }
 
+/*
+ * Determine whether the nickname passed in is a filename that needs to
+ * be loaded as a PEM or a regular NSS nickname. 
+ *
+ * returns 1 for a file
+ * returns 0 for not a file (NSS nickname)
+ */
+static int is_file(const char *filename) {
+    struct stat st;
+
+    if (filename == NULL)
+      return 0;
+
+    if (stat(filename, &st) == 0) {
+      if (S_ISREG(st.st_mode))
+        return 1;
+    }
+    return 0;
+}
+
+static int
+nss_load_cert(struct SessionHandle *data, const char *filename, PRBool cacert)
+{
+  CERTCertificate *cert;
+  void *proto_win = NULL;
+  CK_SLOT_ID slotID;
+  PK11SlotInfo * slot = NULL;
+  PK11GenericObject *rv;
+  CK_ATTRIBUTE *attrs;
+  CK_ATTRIBUTE theTemplate[20];
+  CK_BBOOL cktrue = CK_TRUE;
+  CK_BBOOL ckfalse = CK_FALSE;
+  CK_OBJECT_CLASS objClass = CKO_CERTIFICATE;
+  char *nickname = NULL;
+  char *slotname = NULL;
+  char *n;
+
+  /* If there is no slash in the filename it is assumed to be a regular
+   * NSS nickname.
+   */
+  if (is_file(filename)) {
+    n = strrchr(filename, '/');
+    if (n)
+      n++;
+  } else {
+    /* A nickname from the NSS internal database */
+    nickname = strdup(filename);
+    goto done;
+  }
+
+  attrs = theTemplate;
+
+  /* All CA and trust objects go into slot 0. Other slots are used
+   * for storing certificates. With each new user certificate we increment
+   * the slot count. We only support 1 user certificate right now.
+   */
+  if (cacert) {
+    slotID = 0;
+  } else {
+    slotID = 1;
+  } 
+  
+  slotname = (char *)malloc(SLOTSIZE);
+  nickname = (char *)malloc(PATH_MAX);
+  snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
+  snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", slotID, n);
+
+  slot = PK11_FindSlotByName(slotname);
+  
+  if (!slot) {
+    free(slotname);
+    free(nickname);
+    return 0;
+  }
+  
+  PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) ); attrs++;
+  PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
+  PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename, strlen(filename)+1); attrs++;
+  if (cacert) {
+    PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) ); attrs++;
+  } else {
+    PK11_SETATTRS(attrs, CKA_TRUST, &ckfalse, sizeof(CK_BBOOL) ); attrs++;
+  }
+
+  /* This load the certificate in our PEM module into the appropriate
+   * slot.
+   */
+  rv = PK11_CreateGenericObject(slot, theTemplate, 4, PR_FALSE /* isPerm */);
+
+  PK11_FreeSlot(slot);
+
+  free(slotname);
+  if (rv == NULL) {
+      free(nickname);
+      return 0;
+  }
+
+done:
+  /* Double-check that the certificate or nickname requested exists in
+   * either the token or the NSS certificate database.
+   */
+  if (!cacert) {
+    cert = PK11_FindCertFromNickname((char *)nickname, proto_win);
+
+    /* An invalid nickname was passed in */
+    if (cert == NULL) {
+      PR_SetError(SEC_ERROR_UNKNOWN_CERT, 0);
+      return 0;
+    }
+
+    CERT_DestroyCertificate(cert);
+  }
+  free(nickname);
+
+  return 1;
+}
+
+static int nss_load_key(char *key_file)
+{
+  PK11SlotInfo * slot = NULL;
+  PK11GenericObject *rv;
+  CK_ATTRIBUTE *attrs;
+  CK_ATTRIBUTE theTemplate[20];
+  CK_BBOOL cktrue = CK_TRUE;
+  CK_OBJECT_CLASS objClass = CKO_PRIVATE_KEY;
+  CK_SLOT_ID slotID;
+  char *slotname = NULL;
+
+  attrs = theTemplate;
+
+  /* FIXME: grok the various file types */
+
+  /* FIXME: shouldn't be hardcoded */
+  slotID = 1;
+
+  slotname = (char *)malloc(SLOTSIZE);
+  snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
+
+  slot = PK11_FindSlotByName(slotname);
+  free(slotname);
+
+  if (!slot) {
+    return 0;
+  }
+
+  PK11_SETATTRS(attrs, CKA_CLASS, &objClass, sizeof(objClass) ); attrs++;
+  PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
+  PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)key_file, strlen(key_file)+1); attrs++;
+
+  /* When adding an encrypted key the PKCS#11 will be set as removed */
+  rv = PK11_CreateGenericObject(slot, theTemplate, 3, PR_FALSE /* isPerm */);
+  if (rv == NULL) {
+    PR_SetError(SEC_ERROR_BAD_KEY, 0);
+    return 0;
+  }
+
+  /* This will force the token to be seen as re-inserted */
+  PK11_IsPresent(slot);
+
+  parg->retryCount = 0;
+  /* parg is initialized in nss_Init_Tokens() */
+  if (PK11_Authenticate(slot, PR_TRUE, parg) != SECSuccess) {
+    return 0;
+  }
+
+  return 1;
+}
+
+static int display_error(struct connectdata *conn, PRInt32 err, const char *filename) {
+  switch(err) {
+    case SEC_ERROR_BAD_PASSWORD:
+      failf(conn->data, "Unable to load client key: Incorrect password\n");
+      return 1;
+    case SEC_ERROR_UNKNOWN_CERT:
+      failf(conn->data, "Unable to load certificate %s\n", filename);
+      return 1;
+  }
+  return 0; /* The caller will print a generic error */
+}
+
+static int cert_stuff(struct connectdata *conn, char *cert_file, char *key_file)
+{
+  struct SessionHandle *data = conn->data;
+  int rv = 0;
+
+  if (cert_file)
+    rv = nss_load_cert(data, cert_file, PR_FALSE);  
+    if (!rv) {
+      if (!display_error(conn, PR_GetError(), cert_file))
+        failf(data, "Unable to load client cert %d.", PR_GetError());
+      return 0;
+    }
+  if (key_file || (is_file(cert_file) )) {
+    if (key_file)
+      rv = nss_load_key(key_file);
+    else
+      rv = nss_load_key(cert_file);
+    if (!rv) {
+      if (!display_error(conn, PR_GetError(), key_file))
+        failf(data, "Unable to load client key %d.", PR_GetError());
+
+      return 0;
+    }
+  }
+  return 1;
+}
+
 static char * nss_get_password(PK11SlotInfo * slot, PRBool retry, void *arg)
 {
   pphrase_arg_t *parg = (pphrase_arg_t *) arg;
-  (void)slot; /* unused */
-  (void)retry; /* unused */
+  parg->retryCount++;
+  if (parg->retryCount > 2)
+    return NULL;
   if(parg->data->set.key_passwd)
     return (char *)PORT_Strdup((char *)parg->data->set.key_passwd);
   else
     return NULL;
 }
 
-static SECStatus nss_Init_Tokens(struct connectdata * conn)
+static char * nss_no_password(PK11SlotInfo *slot, PRBool retry, void *arg)
+{
+   return NULL;
+}
+
+static SECStatus nss_Init_Tokens(struct SessionHandle *data)
 {
   PK11SlotList *slotList;
   PK11SlotListElement *listEntry;
   SECStatus ret, status = SECSuccess;
-  pphrase_arg_t *parg;
 
-  parg = (pphrase_arg_t *) malloc(sizeof(*parg));
+  if (!parg)
+      parg = (pphrase_arg_t *) malloc(sizeof(*parg));
   parg->retryCount = 0;
-  parg->data = conn->data;
+  parg->data = data;
 
   PK11_SetPasswordFunc(nss_get_password);
 
@@ -253,10 +487,10 @@ static SECStatus nss_Init_Tokens(struct 
 
     if(PK11_NeedLogin(slot) && PK11_NeedUserInit(slot)) {
       if(slot == PK11_GetInternalKeySlot()) {
-        failf(conn->data, "The NSS database has not been initialized.\n");
+        failf(data, "The NSS database has not been initialized.\n");
       }
       else {
-        failf(conn->data, "The token %s has not been initialized.",
+        failf(data, "The token %s has not been initialized.",
               PK11_GetTokenName(slot));
       }
       PK11_FreeSlot(slot);
@@ -265,6 +499,8 @@ static SECStatus nss_Init_Tokens(struct 
 
     ret = PK11_Authenticate(slot, PR_TRUE, parg);
     if(SECSuccess != ret) {
+      if (PR_GetError() == SEC_ERROR_BAD_PASSWORD)
+        infof(data, "The password for token '%s' is incorrect\n", PK11_GetTokenName(slot));
       status = SECFailure;
       break;
     }
@@ -272,15 +508,59 @@ static SECStatus nss_Init_Tokens(struct 
     PK11_FreeSlot(slot);
   }
 
-  free(parg);
   return status;
 }
 
 static SECStatus BadCertHandler(void *arg, PRFileDesc * socket)
 {
   SECStatus success = SECSuccess;
-  (void)arg;
-  (void)socket;
+  struct connectdata *conn = (struct connectdata *)arg;
+  PRErrorCode err = PR_GetError();
+  CERTCertificate *cert = NULL;
+  char *subject, *issuer;
+
+  if (verify_done)
+      return success;
+
+  verify_done = 1;
+  cert = SSL_PeerCertificate(socket);
+  subject = CERT_NameToAscii(&cert->subject);
+  issuer = CERT_NameToAscii(&cert->issuer);
+  CERT_DestroyCertificate(cert);
+
+  switch(err) {
+  case SEC_ERROR_CA_CERT_INVALID:
+    infof(conn->data, "Issuer certificate is invalid: '%s'\n", issuer);
+    if (conn->data->set.ssl.verifypeer)
+      success = SECFailure;
+    break;
+  case SEC_ERROR_UNTRUSTED_ISSUER:
+    if (conn->data->set.ssl.verifypeer)
+      success = SECFailure;
+    infof(conn->data, "Certificate is signed by an untrusted issuer: '%s'\n", issuer);
+    break;
+  case SSL_ERROR_BAD_CERT_DOMAIN:
+    if (conn->data->set.ssl.verifypeer)
+      success = SECFailure;
+    infof(conn->data, "common name: %s (does not match '%s')\n",
+          subject, conn->host.dispname);
+    break;
+  case SEC_ERROR_EXPIRED_CERTIFICATE:
+    if (conn->data->set.ssl.verifypeer)
+      success = SECFailure;
+    infof(conn->data, "Remote Certificate has expired.\n");
+    break;
+  default:
+    if (conn->data->set.ssl.verifypeer)
+      success = SECFailure;
+    infof(conn->data, "Bad certificate received. Subject = '%s', Issuer = '%s'\n", subject, issuer);
+    break;
+  }
+  if (success == SECSuccess)
+    infof(conn->data, "SSL certificate verify ok.\n");
+  PR_Free(subject);
+  PR_Free(issuer);
+  curlerr = CURLE_SSL_CACERT;
 
   return success;
 }
@@ -295,6 +575,52 @@ static SECStatus HandshakeCallback(PRFil
   return SECSuccess;
 }
 
+static void display_conn_info(struct connectdata *conn, PRFileDesc * socket)
+{
+  SSLChannelInfo channel;
+  SSLCipherSuiteInfo suite;
+  CERTCertificate *cert;
+  char *subject, *issuer, *common_name;
+  PRExplodedTime printableTime;
+  char timeString[256];
+  PRTime notBefore, notAfter;
+
+  if (SSL_GetChannelInfo(socket, &channel, sizeof channel) ==
+    SECSuccess && channel.length == sizeof channel &&
+    channel.cipherSuite) {
+    if (SSL_GetCipherSuiteInfo(channel.cipherSuite,
+      &suite, sizeof suite) == SECSuccess) {
+      infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
+    }
+  }
+
+  infof(conn->data, "Server certificate:\n");
+
+  cert = SSL_PeerCertificate(socket);
+  subject = CERT_NameToAscii(&cert->subject);
+  issuer = CERT_NameToAscii(&cert->issuer);
+  common_name = CERT_GetCommonName(&cert->subject);
+  infof(conn->data, "\tsubject: %s\n", subject);
+
+  CERT_GetCertTimes(cert, &notBefore, &notAfter);
+  PR_ExplodeTime(notBefore, PR_GMTParameters, &printableTime);
+  PR_FormatTime(timeString, 256, "%b %d %H:%M:%S %Y GMT", &printableTime);
+  infof(conn->data, "\tstart date: %s\n", timeString);
+  PR_ExplodeTime(notAfter, PR_GMTParameters, &printableTime);
+  PR_FormatTime(timeString, 256, "%b %d %H:%M:%S %Y GMT", &printableTime);
+  infof(conn->data, "\texpire date: %s\n", timeString);
+  infof(conn->data, "\tcommon name: %s\n", common_name);
+  infof(conn->data, "\tissuer: %s\n", issuer);
+
+  PR_Free(subject);
+  PR_Free(issuer);
+  PR_Free(common_name);
+
+  CERT_DestroyCertificate(cert);
+
+  return;
+}
+
 /**
  *
  * Callback to pick the SSL client certificate.
@@ -309,24 +635,42 @@ static SECStatus SelectClientCert(void *
   char *nickname = (char *)arg;
   void *proto_win = NULL;
   SECStatus secStatus = SECFailure;
+  PK11SlotInfo *slot;
   (void)caNames;
 
   proto_win = SSL_RevealPinArg(socket);
 
+  if (!nickname)
+    return secStatus;
+
   cert = PK11_FindCertFromNickname(nickname, proto_win);
   if(cert) {
-    privKey = PK11_FindKeyByAnyCert(cert, proto_win);
-    if(privKey) {
-      secStatus = SECSuccess;
-    }
-    else {
-      CERT_DestroyCertificate(cert);
+
+    if (!strncmp(nickname, "PEM Token", 9)) {
+      CK_SLOT_ID slotID = 1; /* hardcoded for now */
+      char * slotname = (char *)malloc(SLOTSIZE);
+      snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
+      slot = PK11_FindSlotByName(slotname);
+      privKey = PK11_FindPrivateKeyFromCert(slot, cert, NULL);
+      PK11_FreeSlot(slot);
+      free(slotname);
+      if(privKey) {
+        secStatus = SECSuccess;
+      }
+    } else {
+      privKey = PK11_FindKeyByAnyCert(cert, proto_win);
+      if(privKey) {
+        secStatus = SECSuccess;
+      }
     }
   }
 
   if(secStatus == SECSuccess) {
     *pRetCert = cert;
     *pRetKey = privKey;
+  } else {
+    if (cert)
+      CERT_DestroyCertificate(cert);
   }
 
   return secStatus;
@@ -397,6 +741,8 @@ void Curl_nss_close(struct connectdata *
     }
     connssl->use = FALSE; /* get back to ordinary socket usage */
   }
+  if (select_nickname)
+    free(select_nickname);
 }
 
 /*
@@ -418,31 +764,52 @@ CURLcode Curl_nss_connect(struct connect
   curl_socket_t sockfd = conn->sock[sockindex];
   struct ssl_connect_data *connssl = &conn->ssl[sockindex];
   SECStatus rv;
-  int curlerr = CURLE_SSL_CONNECT_ERROR;
+  char *configstring = NULL;
+  char *certDir = NULL;
+
+  curlerr = CURLE_SSL_CONNECT_ERROR;
+  certDir = getenv("SSL_DIR"); /* Look in $SSL_DIR */
+
+  if (!certDir) {
+    struct stat st;
+
+    if (stat(SSL_DIR, &st) == 0)
+      if (S_ISDIR(st.st_mode)) {
+        certDir = "/etc/pki/nssdb";
+      }
+  }
 
   /* FIXME. NSS doesn't support multiple databases open at the same time. */
   if(!initialized) {
-    if(!data->set.ssl.CAfile) {
-      if(data->set.ssl.verifypeer) {
-        failf(data, "No NSS cacert database specified.");
-        return CURLE_SSL_CACERT_BADFILE;
-      }
-      else {
-        rv = NSS_NoDB_Init(NULL);
-        noverify = 1;
-      }
+    if(!certDir) {
+      rv = NSS_NoDB_Init(NULL);
     }
     else {
-      rv = NSS_Initialize(data->set.ssl.CAfile, NULL, NULL, "secmod.db",
+      rv = NSS_Initialize(certDir, NULL, NULL, "secmod.db",
                           NSS_INIT_READONLY);
     }
     if(rv != SECSuccess) {
       curlerr = CURLE_SSL_CACERT_BADFILE;
       goto error;
     }
-  }
+    configstring = (char *)malloc(4096);
+
+    NSS_SetDomesticPolicy();
 
-  NSS_SetDomesticPolicy();
+    PR_snprintf(configstring, 4096, "library=%s name=PEM", pem_library);
+//    PR_snprintf(configstring, 4096, "library=%s name=PEM parameters=\"NSS=\"trustorder=75\"\"", pem_library);
+//     PR_snprintf(configstring, 4096, "library=/usr/lib/libnsspem.so name=PEM parameters=\"/etc/pki/tls/certs/ca-bundle.crt\" NSS=\"trustorder=75\"");
+
+    mod = SECMOD_LoadUserModule(configstring, NULL, PR_FALSE);
+    if (!mod || !mod->loaded) {
+      if (mod) {
+        SECMOD_DestroyModule(mod);
+        mod = NULL;
+      }
+      infof(data, "WARNING: failed to load NSS PEM library %s. Using OpenSSL PEM certificates will not work.\n", pem_library);
+    }
+    free(configstring);
+  }
 
   model = PR_NewTCPSocket();
   if(!model)
@@ -482,26 +849,92 @@ CURLcode Curl_nss_connect(struct connect
     goto error;
 
   if(data->set.ssl.cipher_list) {
-    if(set_ciphers(data, model, data->set.ssl.cipher_list) != SECSuccess)
+    if(set_ciphers(data, model, data->set.ssl.cipher_list) != SECSuccess) {
+      curlerr = CURLE_SSL_CIPHER;
       goto error;
+    }
   }
 
-  if(SSL_BadCertHook(model, (SSLBadCertHandler) BadCertHandler, NULL)
-     != SECSuccess)
+  if(SSL_BadCertHook(model, (SSLBadCertHandler) BadCertHandler, conn)
+     != SECSuccess) {
     goto error;
+  }
   if(SSL_HandshakeCallback(model, (SSLHandshakeCallback) HandshakeCallback,
                            NULL) != SECSuccess)
     goto error;
 
+  if (mod && data->set.ssl.CAfile) {
+    rv = nss_load_cert(data, data->set.ssl.CAfile, PR_TRUE);
+  } else if (data->set.ssl.CApath) {
+    struct stat st;
+    PRDir      *dir;
+    PRDirEntry *entry;
+
+    if (stat(data->set.ssl.CApath, &st) == -1)
+      curlerr = CURLE_SSL_CACERT_BADFILE;
+      goto error;
+
+    if (S_ISDIR(st.st_mode)) {
+      dir = PR_OpenDir(data->set.ssl.CApath);
+      int rv;
+      do {
+        entry = PR_ReadDir(dir, PR_SKIP_BOTH | PR_SKIP_HIDDEN);
+
+        if (entry) {
+          char fullpath[PATH_MAX];
+
+          snprintf(fullpath, sizeof(fullpath), "%s/%s", data->set.ssl.CApath, entry->name);
+          rv = nss_load_cert(data, fullpath, PR_TRUE);
+        }
+      /* This is purposefully tolerant of errors so non-PEM files
+       * can be in the same directory */
+      } while (entry != NULL);
+      PR_CloseDir(dir);
+    }
+  }
+  infof(data,
+        "  CAfile: %s\n"
+        "  CApath: %s\n",
+        data->set.ssl.CAfile ? data->set.ssl.CAfile : "none",
+        data->set.ssl.CApath ? data->set.ssl.CApath : "none");
+
   if(data->set.cert) {
+    char * n;
+    char * nickname;
+
+    nickname = (char *)malloc(PATH_MAX);
+    if (is_file(data->set.cert)) {
+      n = strrchr(data->set.cert, '/');
+      if (n) {
+          n++; /* skip last slash */
+          snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", 1, n);
+      }
+    } else {
+        strncpy(nickname, data->set.cert, PATH_MAX);
+    }
+    if(nss_Init_Tokens(conn->data) != SECSuccess) {
+      free(nickname);
+      goto error;
+    }
+    if (!cert_stuff(conn, data->set.cert, data->set.key)) {
+      /* failf() is already done in cert_stuff() */
+      free(nickname);
+      return CURLE_SSL_CERTPROBLEM;
+    }
+
+    select_nickname = strdup(nickname);
     if(SSL_GetClientAuthDataHook(model,
                                  (SSLGetClientAuthData) SelectClientCert,
-                                 (void *)data->set.cert) != SECSuccess) {
+                                 (void *)select_nickname) != SECSuccess) {
       curlerr = CURLE_SSL_CERTPROBLEM;
       goto error;
     }
-    if(nss_Init_Tokens(conn) != SECSuccess)
-      goto error;
+
+    free(nickname);
+    free(parg);
+
+    /* No longer return the password, lets us free parg */
+    PK11_SetPasswordFunc(nss_no_password);
   }
 
   /* Import our model socket  onto the existing file descriptor */
@@ -509,6 +942,7 @@ CURLcode Curl_nss_connect(struct connect
   connssl->handle = SSL_ImportFD(model, connssl->handle);
   if(!connssl->handle)
     goto error;
+  PR_Close(model); /* We don't need this any more */
 
   /* Force handshake on next I/O */
   SSL_ResetHandshake(connssl->handle, /* asServer */ PR_FALSE);
@@ -518,14 +952,17 @@ CURLcode Curl_nss_connect(struct connect
   /* Force the handshake now */
   if (SSL_ForceHandshakeWithTimeout(connssl->handle,
                                     PR_SecondsToInterval(HANDSHAKE_TIMEOUT))
-      != SECSuccess)
+      != SECSuccess) {
     goto error;
+  }
+
+  display_conn_info(conn, connssl->handle);
 
   return CURLE_OK;
 
 error:
   err = PR_GetError();
-  failf(data, "NSS error %d", err);
+  infof(data, "NSS error %d\n", err);
   if(model)
     PR_Close(model);
   return curlerr;


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/curl/OLPC-2/.cvsignore,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- .cvsignore	11 Apr 2007 18:20:54 -0000	1.24
+++ .cvsignore	12 Sep 2007 17:16:35 -0000	1.25
@@ -1,5 +1 @@
-curl-7.15.4.tar.bz2
-curl-7.15.5.tar.bz2
-curl-7.16.0.tar.bz2
-curl-7.16.1.tar.bz2
-curl-7.16.2.tar.bz2
+curl-7.16.4.tar.bz2


Index: curl.spec
===================================================================
RCS file: /cvs/pkgs/rpms/curl/OLPC-2/curl.spec,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- curl.spec	11 May 2007 12:07:53 -0000	1.49
+++ curl.spec	12 Sep 2007 17:16:35 -0000	1.50
@@ -1,19 +1,22 @@
-%define ldap_version 2.3
+# get the current ldap library version to link against automatically
+%define ldap_version %(readlink %{_libdir}/libldap.so | sed 's,.*libldap-\\([0-9.]*\\)\\.so\\..*,\\1,')
 
 Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
 Name: curl 
-Version: 7.16.2
-Release: 3%{?dist}
+Version: 7.16.4
+Release: 6%{?dist}
 License: MIT
 Group: Applications/Internet
 Source: http://curl.haxx.se/download/%{name}-%{version}.tar.bz2
-Patch0: curl-7.14.1-nousr.patch
-Patch1: curl-7.15.0-curl_config-version.patch
-Patch2: curl-7.15.3-multilib.patch
-Patch3: curl-7.16.0-privlibs.patch
+Patch1: curl-7.15.3-multilib.patch
+Patch2: curl-7.16.0-privlibs.patch
+Patch3: curl-7.16.4-ftp.patch
+Patch4: curl-7.16.4-nsspem.patch
+Provides: webclient
 URL: http://curl.haxx.se/
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: openssl-devel, libtool, pkgconfig, libidn-devel
+BuildRequires: libtool, pkgconfig, libidn-devel
+BuildRequires: nss-devel >= 3.11.7-7
 
 %description
 cURL is a tool for getting files from FTP, HTTP, Gopher, Telnet, and
@@ -25,7 +28,7 @@
 %package devel
 Group: Development/Libraries
 Requires: %{name} = %{version}-%{release}
-Requires: openssl-devel, libidn-devel, pkgconfig, automake
+Requires: libidn-devel, pkgconfig, automake
 Summary: Files needed for building applications with libcurl
 
 %description devel
@@ -36,31 +39,31 @@
 
 %prep
 %setup -q 
-%patch0 -p1 -b .nousr
-%patch1 -p1 -b .ver
-%patch2 -p1 -b .multilib
-%patch3 -p1 -b .privlibs
+%patch1 -p1 -b .multilib
+%patch2 -p1 -b .privlibs
+%patch3 -p1 -b .ftp
+%patch4 -p1 -b .nsspem
 
 %build
-aclocal
-libtoolize --force
-./reconf
-
-if pkg-config openssl ; then
-	CPPFLAGS=`pkg-config --cflags openssl`; export CPPFLAGS
-	LDFLAGS=`pkg-config --libs openssl`; export LDFLAGS
+if pkg-config nss ; then
+	CPPFLAGS=`pkg-config --cflags nss`; export CPPFLAGS
+	LDFLAGS=`pkg-config --libs nss`; export LDFLAGS
 fi
-%configure --with-ssl=%{_prefix} --enable-ipv6 \
+%configure --without-ssl --with-nss=%{_prefix} --enable-ipv6 \
 	--with-ca-bundle=%{_sysconfdir}/pki/tls/certs/ca-bundle.crt \
 	--with-gssapi=%{_prefix}/kerberos --with-libidn \
 	--with-ldap-lib=libldap-%{ldap_version}.so.0 \
 	--with-lber-lib=liblber-%{ldap_version}.so.0 \
 	--disable-static
+sed -i -e 's,-L/usr/lib ,,g;s,-L/usr/lib64 ,,g;s,-L/usr/lib$,,g;s,-L/usr/lib64$,,g' \
+	Makefile libcurl.pc
 make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
 
 %install
 rm -rf $RPM_BUILD_ROOT
-%makeinstall
+
+make DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p" install
+
 rm -f ${RPM_BUILD_ROOT}%{_libdir}/libcurl.la
 install -d $RPM_BUILD_ROOT/%{_datadir}/aclocal
 install -m 644 docs/libcurl/libcurl.m4 $RPM_BUILD_ROOT/%{_datadir}/aclocal
@@ -90,6 +93,7 @@
 %files devel
 %defattr(-,root,root)
 %doc docs/examples/*.c docs/examples/Makefile.example docs/INTERNALS
+%doc docs/CONTRIBUTE
 %{_bindir}/curl-config*
 %{_includedir}/curl
 %{_libdir}/*.so
@@ -99,6 +103,45 @@
 %{_datadir}/aclocal/libcurl.m4
 
 %changelog
+* Mon Sep 10 2007 Jindrich Novy <jnovy at redhat.com> 7.16.4-6
+- provide webclient (#225671)
+
+* Thu Sep  6 2007 Jindrich Novy <jnovy at redhat.com> 7.16.4-5
+- add support for the NSS PKCS#11 pem reader so the command-line is the
+  same for both OpenSSL and NSS by Rob Crittenden (rcritten at redhat.com)
+- switch to NSS again
+
+* Mon Sep  3 2007 Jindrich Novy <jnovy at redhat.com> 7.16.4-4
+- revert back to use OpenSSL (#266021)
+
+* Mon Aug 27 2007 Jindrich Novy <jnovy at redhat.com> 7.16.4-3
+- don't use openssl, use nss instead
+
+* Fri Aug 10 2007 Jindrich Novy <jnovy at redhat.com> 7.16.4-2
+- fix anonymous ftp login (#251570), thanks to David Cantrell
+
+* Wed Jul 11 2007 Jindrich Novy <jnovy at redhat.com> 7.16.4-1
+- update to 7.16.4
+
+* Mon Jun 25 2007 Jindrich Novy <jnovy at redhat.com> 7.16.3-1
+- update to 7.16.3
+- drop .print patch, applied upstream
+- next series of merge review fixes by Paul Howarth
+- remove aclocal stuff, no more needed
+- simplify makefile arguments
+- don't reference standard library paths in libcurl.pc
+- include docs/CONTRIBUTE
+
+* Mon Jun 18 2007 Jindrich Novy <jnovy at redhat.com> 7.16.2-5
+- don't print like crazy (#236981), backported from upstream CVS
+
+* Fri Jun 15 2007 Jindrich Novy <jnovy at redhat.com> 7.16.2-4
+- another series of review fixes (#225671),
+  thanks to Paul Howarth
+- check version of ldap library automatically
+- don't use %%makeinstall and preserve timestamps
+- drop useless patches
+
 * Fri May 11 2007 Jindrich Novy <jnovy at redhat.com> 7.16.2-3
 - add automake BR to curl-devel to fix aclocal dir. ownership,
   thanks to Patrice Dumas


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/curl/OLPC-2/sources,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- sources	11 Apr 2007 18:20:54 -0000	1.25
+++ sources	12 Sep 2007 17:16:35 -0000	1.26
@@ -1,2 +1 @@
-acdab0b0467c55e10ed02d2afed80575  curl-7.16.1.tar.bz2
-37a1de15c4300ca9413d39d2bcea9b36  curl-7.16.2.tar.bz2
+ffa6d1f4e28ca493a43f9dc17882c4d8  curl-7.16.4.tar.bz2


--- curl-7.14.1-nousr.patch DELETED ---


--- curl-7.15.0-curl_config-version.patch DELETED ---




More information about the scm-commits mailing list