pike.git / lib / modules / Tools.pmod / X509.pmod

version» Context lines:

pike.git/lib/modules/Tools.pmod/X509.pmod:1:   #pike __REAL_VERSION__      /* -  * $Id: X509.pmod,v 1.13 2000/10/22 11:24:26 sigge Exp $ +  * $Id: X509.pmod,v 1.14 2001/08/23 16:18:25 grubba Exp $    *    * Some random functions for creating RFC-2459 style X.509 certificates.    *    */      #if constant(Standards.ASN1.Types.asn1_sequence)      import Standards.ASN1.Types;   import Standards.PKCS;      // Note: Redump this module if you change X509_DEBUG   #ifdef X509_DEBUG   #define X509_WERR werror   #else   #define X509_WERR   #endif      object make_time(int t)   { -  mapping m = gmtime(t); +  object(Calendar.Second) second = Calendar.Second(t)->set_timezone("UTC");    -  if (m->year >= 150) +  if (second->year() >= 2050) {    throw( ({ "Tools.X509.make_time: "    "Times later than 2049 not supported yet\n",    backtrace() }) ); -  +  }       return asn1_utc(sprintf("%02d%02d%02d%02d%02d%02dZ", -  m->year % 100, -  m->mon + 1, -  m->mday, -  m->hour, -  m->min, -  m->sec)); +  second->year() % 100, +  second->month_no(), +  second->month_day(), +  second->hour_no(), +  second->minute_no(), +  second->second_no()));   }      /* Returns a mapping similar to that returned by gmtime */   mapping parse_time(object asn1)   {    if ((asn1->type_name != "UTCTime")    || (strlen(asn1->value) != 13))    return 0;       sscanf(asn1->value, "%[0-9]s%c", string s, int c);