mirror of
https://github.com/brunoos/luasec.git
synced 2025-07-03 01:24:34 +02:00
x509: Handle non-UTF8 ASN1 strings correctly by converting them to UTF8.
This commit is contained in:
parent
4a95102cc8
commit
24f5b27eb4
16
src/x509.c
16
src/x509.c
@ -75,12 +75,20 @@ static void push_asn1_objname(lua_State* L, ASN1_OBJECT *object, int no_name)
|
||||
*/
|
||||
static void push_asn1_string(lua_State* L, ASN1_STRING *string)
|
||||
{
|
||||
if (string)
|
||||
lua_pushlstring(L, (char*)ASN1_STRING_data(string),
|
||||
ASN1_STRING_length(string));
|
||||
else
|
||||
if (string) {
|
||||
unsigned char *data;
|
||||
size_t len = ASN1_STRING_to_UTF8(&data, string);
|
||||
|
||||
if (len >= 0) {
|
||||
lua_pushlstring(L, (char *)data, len);
|
||||
OPENSSL_free(data);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a human readable time.
|
||||
|
Loading…
x
Reference in New Issue
Block a user