1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-11 04:53:56 +00:00

1. Added NULL check on util_to_cer

2. Added digest() to tls.GenerateCertificate()
3. Added first rev of Simulated Server, for Agent Self Update Test
This commit is contained in:
Bryan Roe
2022-06-06 23:50:09 -07:00
parent d8e6e7f3ab
commit dec0fcb5c0
3 changed files with 155 additions and 1 deletions

View File

@@ -2681,6 +2681,8 @@ duk_ret_t ILibDuktape_TLS_generateCertificate(duk_context *ctx)
char *data;
int noUsages = 0;
int certType = CERTIFICATE_TLS_CLIENT;
char certHash[UTIL_SHA384_HASHSIZE];
char fingerprint[150];
if (!duk_is_null_or_undefined(ctx, 1) && duk_is_object(ctx, 1))
{
@@ -2695,9 +2697,16 @@ duk_ret_t ILibDuktape_TLS_generateCertificate(duk_context *ctx)
memcpy_s((void*)Duktape_GetBuffer(ctx, -1, NULL), len, data, len);
duk_push_buffer_object(ctx, -1, 0, len, DUK_BUFOBJ_NODEJS_BUFFER);
ILibDuktape_WriteID(ctx, "tls.pfxCertificate");
util_certhash2(cert.x509, certHash);
util_tohex2(certHash, UTIL_SHA384_HASHSIZE, fingerprint);
duk_push_string(ctx, fingerprint); // [cert][digest]
duk_put_prop_string(ctx, -2, "digest"); // [cert]
util_free(data);
util_freecert(&cert);
passphrase = NULL;
return 1;
}
duk_ret_t ILibDuktape_TLS_loadpkcs7b(duk_context *ctx)