Name
SPVM::Net::SSLeay::GENERAL_NAME - GENERAL_NAME Data Structure in OpenSSL
Description
Net::SSLeay::GENERAL_NAME class in SPVM represents GENERAL_NAME data structure in OpenSSL
Usage
use Net::SSLeay::GENERAL_NAME;
Class Methods
new
static method new : Net::SSLeay::GENERAL_NAME ();
Calls native GENERAL_NAME_new function, creates a new Net::SSLeay::GENERAL_NAME object, sets the pointer value of the object to the return value of the native function, and returns the new object.
Exceptions:
If GENERAL_NAME_new failed, an exception is thrown with eval_error_id
set to the basic type ID of Net::SSLeay::Error class.
Instance Methods
type
method get_type : int ();
Returns the value of type
member variable in GENERAL_NAME
data strcuture.
get_data_as_string
method get_data_as_string : string ();
Creates a string from the data in GENERAL_NAME
, and returns it.
Implementation:
The following codes are native C codes to create a string corresponding to the type. self
is the pointer value of the instance.
switch (self->type) {
case GEN_OTHERNAME: {
ASN1_STRING* data_asn1_string = self->d.otherName->value->value.utf8string;
const char* data = ASN1_STRING_get0_data(data_asn1_string);
int32_t data_length = ASN1_STRING_length(data_asn1_string);
obj_data_as_string = env->new_string(env, stack, data, data_length);
break;
}
case GEN_EMAIL:
case GEN_DNS:
case GEN_URI:
{
ASN1_STRING* data_asn1_string = self->d.ia5;
const char* data = ASN1_STRING_get0_data(data_asn1_string);
int32_t data_length = ASN1_STRING_length(data_asn1_string);
obj_data_as_string = env->new_string(env, stack, data, data_length);
break;
}
case GEN_DIRNAME: {
char * buf = X509_NAME_oneline(self->d.dirn, NULL, 0);
obj_data_as_string = env->new_string(env, stack, buf, strlen(buf));
OPENSSL_free(buf);
break;
}
case GEN_RID: {
char buf[2501] = {0};
int len = OBJ_obj2txt(buf, sizeof(buf), self->d.rid, 1);
if (len < 0 || len > (int)((sizeof(buf) - 1))) {
return env->die(env, stack, "The length of d.rid is invalid.", __func__, FILE_NAME, __LINE__);
}
obj_data_as_string = env->new_string_nolen(env, stack, buf);
break;
}
case GEN_IPADD: {
const char* data = self->d.ip->data;
int32_t data_length = self->d.ip->length;
obj_data_as_string = env->new_string(env, stack, data, data_length);
break;
}
default : {
return env->die(env, stack, "The value of type member variable: %d.", self->type, __func__, FILE_NAME, __LINE__);
}
}
Exceptions:
If the length of d.rid is invalid, an exception is thrown.
The value of type member variable is invalid, an exception is thrown.
DESTROY
method DESTROY : void ();
Calls native GENERAL_NAME_free function given the pointer value of the instance if no_free
flag of the instance is not a true value.
See Also
Copyright & License
Copyright (c) 2024 Yuki Kimoto
MIT License