mirror of
https://github.com/brunoos/luasec.git
synced 2025-07-03 09:34: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,11 +75,19 @@ 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)
|
static void push_asn1_string(lua_State* L, ASN1_STRING *string)
|
||||||
{
|
{
|
||||||
if (string)
|
if (string) {
|
||||||
lua_pushlstring(L, (char*)ASN1_STRING_data(string),
|
unsigned char *data;
|
||||||
ASN1_STRING_length(string));
|
size_t len = ASN1_STRING_to_UTF8(&data, string);
|
||||||
else
|
|
||||||
|
if (len >= 0) {
|
||||||
|
lua_pushlstring(L, (char *)data, len);
|
||||||
|
OPENSSL_free(data);
|
||||||
|
} else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user