Added new members and required method in to oxs_x509_cert to have valid from date, version and alias
diff --git a/include/oxs_x509_cert.h b/include/oxs_x509_cert.h
index 940cad2..868f15b 100644
--- a/include/oxs_x509_cert.h
+++ b/include/oxs_x509_cert.h
@@ -153,6 +153,36 @@
oxs_x509_cert_get_public_key(oxs_x509_cert_t *x509_cert,
const axutil_env_t *env);
+ /**
+ * Get the date from when the X509 Certificate is valid
+ * @param x509_cert the X509 certificate
+ * @param env pointer to environment struct
+ * @return the date from when the X509 Certificate is valid
+ */
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ oxs_x509_cert_get_valid_from(oxs_x509_cert_t *x509_cert,
+ const axutil_env_t* env);
+
+ /**
+ * Get the version of X509 Certificate
+ * @param x509_cert the X509 certificate
+ * @param env pointer to environment struct
+ * @return the version of X509 certificate
+ */
+ AXIS2_EXTERN int AXIS2_CALL
+ oxs_x509_cert_get_version(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env);
+
+ /**
+ * Get the alias (i.e. friendly name) of X509 Certificate
+ * @param x509_cert the X509 certificate
+ * @param env pointer to environment struct
+ * @return the alias of X509 certificate
+ */
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ oxs_x509_cert_get_alias(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env);
+
/*Setters*/
/**
* Set the serial number of X509 Certificate
diff --git a/src/omxmlsec/openssl/pkcs12_keystore.c b/src/omxmlsec/openssl/pkcs12_keystore.c
index 721c9dd..49558ab 100644
--- a/src/omxmlsec/openssl/pkcs12_keystore.c
+++ b/src/omxmlsec/openssl/pkcs12_keystore.c
@@ -208,6 +208,9 @@
axis2_char_t *x509_common_name = NULL;
EVP_PKEY *pub_key = NULL;
openssl_pkey_t *open_pubkey = NULL;
+ axis2_char_t* x509_cert_valid_from = NULL;
+ int x509_cert_version = 0;
+ axis2_char_t* x509_cert_alias = NULL;
oxs_x509_cert_t *cert_out = NULL;
x509_cert_data = openssl_x509_get_cert_data(env, cert_in);
@@ -217,6 +220,9 @@
x509_cert_finger = openssl_x509_get_info(env, OPENSSL_X509_INFO_FINGER, cert_in);
x509_cert_key_id = openssl_x509_get_subject_key_identifier(env, cert_in);
x509_common_name = openssl_x509_get_common_name(env, cert_in);
+ x509_cert_valid_from = openssl_x509_get_info(env, OPENSSL_X509_INFO_VALID_FROM, cert_in);
+ x509_cert_version = atoi(openssl_x509_get_info(env, OPENSSL_X509_INFO_VERSION, cert_in));
+ x509_cert_alias = openssl_x509_get_alias(env, cert_in);
cert_out = oxs_x509_cert_create(env);
if (!cert_out) {
@@ -231,6 +237,9 @@
oxs_x509_cert_set_serial_number(cert_out, env, openssl_x509_get_serial(env, cert_in));
oxs_x509_cert_set_key_identifier(cert_out, env, x509_cert_key_id);
oxs_x509_cert_set_common_name(cert_out, env, x509_common_name);
+ oxs_x509_cert_set_valid_from(cert_out, env, x509_cert_valid_from);
+ oxs_x509_cert_set_version(cert_out, env, x509_cert_version);
+ oxs_x509_cert_set_alias(cert_out, env, x509_cert_alias);
openssl_x509_get_pubkey(env, cert_in, &pub_key);
open_pubkey = openssl_pkey_create(env);
diff --git a/src/omxmlsec/x509_cert.c b/src/omxmlsec/x509_cert.c
index d1f53f3..094da5b 100644
--- a/src/omxmlsec/x509_cert.c
+++ b/src/omxmlsec/x509_cert.c
@@ -33,6 +33,9 @@
axis2_char_t *data;
axis2_char_t *common_name;
openssl_pkey_t *public_key;
+ axis2_char_t *valid_from;
+ int version;
+ axis2_char_t *alias;
};
@@ -63,6 +66,9 @@
x509_cert->data =NULL;
x509_cert->public_key =NULL;
x509_cert->common_name = NULL;
+ x509_cert->valid_from = NULL;
+ x509_cert->version = 0;
+ x509_cert->alias = NULL;
return x509_cert;
}
@@ -110,6 +116,17 @@
x509_cert->common_name = NULL;
}
+ if(x509_cert->valid_from)
+ {
+ AXIS2_FREE(env->allocator, x509_cert->valid_from);
+ x509_cert->valid_from = NULL;
+ }
+ if(x509_cert->alias)
+ {
+ AXIS2_FREE(env->allocator, x509_cert->alias);
+ x509_cert->alias = NULL;
+ }
+
AXIS2_FREE(env->allocator, x509_cert);
x509_cert = NULL;
@@ -132,6 +149,9 @@
openssl_pkey_increment_ref(x509_cert->public_key, env);
oxs_x509_cert_set_public_key(to, env, x509_cert->public_key);
oxs_x509_cert_set_common_name(to, env, x509_cert->common_name);
+ oxs_x509_cert_set_valid_from(to, env, x509_cert->valid_from);
+ oxs_x509_cert_set_version(to, env, x509_cert->version);
+ oxs_x509_cert_set_alias(to, env, x509_cert->alias);
return AXIS2_SUCCESS;
}
@@ -192,6 +212,27 @@
return x509_cert->public_key;
}
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_x509_cert_get_valid_from(oxs_x509_cert_t *x509_cert,
+ const axutil_env_t* env)
+{
+ return x509_cert->valid_from;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+oxs_x509_cert_get_version(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env)
+{
+ return x509_cert->version;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_x509_cert_get_alias(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env)
+{
+ return x509_cert->alias;
+}
+
AXIS2_EXTERN axis2_char_t * AXIS2_CALL
oxs_x509_cert_get_common_name(oxs_x509_cert_t *x509_cert,
const axutil_env_t *env)
@@ -330,3 +371,43 @@
return AXIS2_SUCCESS;
}
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_x509_cert_set_valid_from(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env,
+ axis2_char_t* valid_from)
+{
+ if(x509_cert->valid_from)
+ {
+ AXIS2_FREE(env->allocator, x509_cert->valid_from);
+ x509_cert->valid_from = NULL;
+ }
+
+ x509_cert->valid_from = axutil_strdup(env, valid_from);
+ return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_x509_cert_set_version(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env,
+ int version)
+{
+ x509_cert->version = version;
+ return AXIS2_SUCCESS;
+}
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_x509_cert_set_alias(oxs_x509_cert_t* x509_cert,
+ const axutil_env_t* env,
+ axis2_char_t* alias)
+{
+ if(x509_cert->alias)
+ {
+ AXIS2_FREE(env->allocator, x509_cert->alias);
+ x509_cert->alias = NULL;
+ }
+
+ x509_cert->alias = axutil_strdup(env, alias);
+ return AXIS2_SUCCESS;
+}
\ No newline at end of file