javacommons/security/src/midpauthenticationmoduleimpl.cpp
branchRCL_3
changeset 21 4376525cdefb
parent 14 04becd199f91
child 24 6c158198356e
equal deleted inserted replaced
19:71c436fe3ce0 21:4376525cdefb
    20 #include "com_nokia_mj_impl_security_midp_authentication_AuthenticationModule.h"
    20 #include "com_nokia_mj_impl_security_midp_authentication_AuthenticationModule.h"
    21 #include "midpauthenticationmodule.h"
    21 #include "midpauthenticationmodule.h"
    22 #include "midpauthenticationmoduleimpl.h"
    22 #include "midpauthenticationmoduleimpl.h"
    23 #include "storagehandler.h"
    23 #include "storagehandler.h"
    24 #include "securityutils.h"
    24 #include "securityutils.h"
       
    25 #include "telutils.h"
    25 #include "javacertstorehandler.h"
    26 #include "javacertstorehandler.h"
    26 #include "securitycommsmessagedefs.h"
    27 #include "securitycommsmessagedefs.h"
    27 #include "javastorage.h"
    28 #include "javastorage.h"
    28 #include "javastoragenames.h"
    29 #include "javastoragenames.h"
    29 #include "logger.h"
    30 #include "logger.h"
    36 #include <openssl/x509_vfy.h>
    37 #include <openssl/x509_vfy.h>
    37 #include <openssl/asn1.h>
    38 #include <openssl/asn1.h>
    38 #include <openssl/err.h>
    39 #include <openssl/err.h>
    39 #include <openssl/rsa.h>
    40 #include <openssl/rsa.h>
    40 #include <openssl/sha.h>
    41 #include <openssl/sha.h>
    41 #include <sys/time.h>
       
    42 #include <string.h>
    42 #include <string.h>
    43 
    43 
    44 using namespace java::security;
    44 using namespace java::security;
    45 using namespace java::storage;
    45 using namespace java::storage;
    46 using namespace java::util;
    46 using namespace java::util;
   453         {
   453         {
   454             ret_code = getErrCode(ERR_get_error());
   454             ret_code = getErrCode(ERR_get_error());
   455             break;
   455             break;
   456         }
   456         }
   457 
   457 
   458         struct timeval tv;
   458         X509_STORE_CTX_set_time(x509_ctx, X509_V_FLAG_USE_CHECK_TIME, TelUtils::getSecureTime());
   459         int i = gettimeofday(&tv, NULL);
       
   460         X509_STORE_CTX_set_time(x509_ctx, X509_V_FLAG_USE_CHECK_TIME, tv.tv_sec);
       
   461         // set the callback for validation - needed for the critical extension
   459         // set the callback for validation - needed for the critical extension
   462         // used by developer certificates
   460         // used by developer certificates
   463         X509_STORE_CTX_set_verify_cb(x509_ctx, verify_callback);
   461         X509_STORE_CTX_set_verify_cb(x509_ctx, verify_callback);
   464 
   462 
   465         // verify certificate
   463         // verify certificate
   473         EXTENDED_KEY_USAGE *extKeyUsage;
   471         EXTENDED_KEY_USAGE *extKeyUsage;
   474         if ((extKeyUsage=(EXTENDED_KEY_USAGE*)X509_get_ext_d2i(end_entity_cert, NID_ext_key_usage, NULL, NULL)) != NULL)
   472         if ((extKeyUsage=(EXTENDED_KEY_USAGE*)X509_get_ext_d2i(end_entity_cert, NID_ext_key_usage, NULL, NULL)) != NULL)
   475         {
   473         {
   476             bool extKeyUsageKnown = false;
   474             bool extKeyUsageKnown = false;
   477             char EXT_KEY_USAGE_OID[80];
   475             char EXT_KEY_USAGE_OID[80];
   478             for (i = 0; i < sk_ASN1_OBJECT_num(extKeyUsage); i++)
   476             for (int i = 0; i < sk_ASN1_OBJECT_num(extKeyUsage); i++)
   479             {
   477             {
   480                 ASN1_OBJECT *usage = sk_ASN1_OBJECT_value(extKeyUsage,i);
   478                 ASN1_OBJECT *usage = sk_ASN1_OBJECT_value(extKeyUsage,i);
   481                 OBJ_obj2txt(EXT_KEY_USAGE_OID,
   479                 OBJ_obj2txt(EXT_KEY_USAGE_OID,
   482                             sizeof(EXT_KEY_USAGE_OID),
   480                             sizeof(EXT_KEY_USAGE_OID),
   483                             usage,
   481                             usage,