From fcb1581a1ccf931a41e880d921cbee2d5db99aa1 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Thu, 28 Feb 2019 15:54:27 +0800 Subject: [PATCH] =?UTF-8?q?keykeeper=E7=9A=84=E6=9C=AC=E5=9C=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E4=BD=BF=E7=94=A8keyring=5Fid:=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E6=8C=87=E7=BA=B9=E4=BD=9C=E4=B8=BAkey=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E5=AF=BC=E5=85=A5=E5=8F=AF=E4=BF=A1=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=9D=9E=E6=B3=95=E8=AF=81=E4=B9=A6=E5=8F=98?= =?UTF-8?q?=E4=B8=BA=E5=90=88=E6=B3=95=E8=AF=81=E4=B9=A6=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=88=B0=E7=9A=84=E4=BB=8D?= =?UTF-8?q?=E6=98=AF=E9=9D=9E=E6=B3=95=E8=AF=81=E4=B9=A6=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20#119=20=E3=80=82=E5=8F=98=E6=9B=B4key=E4=B8=BAkeyri?= =?UTF-8?q?ng=5Fid:is=5Fcert=5Fvalid:=E8=AF=81=E4=B9=A6=E6=8C=87=E7=BA=B9?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/src/key_keeper.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/platform/src/key_keeper.cpp b/platform/src/key_keeper.cpp index 68c6485..0a1f1db 100644 --- a/platform/src/key_keeper.cpp +++ b/platform/src/key_keeper.cpp @@ -519,24 +519,24 @@ struct keyring* key_keeper_release_keyring(future_result_t* result) return &(kyr->head); } -static uchar* get_key_by_cert(X509* cert, int keyring_id, unsigned int* len) +static uchar* get_key_by_cert(X509* cert, int keyring_id, unsigned int* len, int is_cert_valid) { if(cert == NULL) { return NULL; } - char* cert_fgr = NULL; - cert_fgr = ssl_x509_fingerprint(cert, 0); - if(cert_fgr == NULL) + char* cert_fingerprint = NULL; + cert_fingerprint = ssl_x509_fingerprint(cert, 0); + if(cert_fingerprint == NULL) { return NULL; } - char* key = (char*)malloc(HTABLE_MAX_KEY_LEN); + char* key = ALLOC(char, HTABLE_MAX_KEY_LEN); memset(key, 0, HTABLE_MAX_KEY_LEN); - snprintf(key, HTABLE_MAX_KEY_LEN, "%d:", keyring_id); - strncat(key, cert_fgr, HTABLE_MAX_KEY_LEN); + snprintf(key, HTABLE_MAX_KEY_LEN, "%d:%d:", keyring_id, is_cert_valid); + strncat(key, cert_fingerprint, HTABLE_MAX_KEY_LEN); *len = strnlen(key, HTABLE_MAX_KEY_LEN); - free(cert_fgr); + free(cert_fingerprint); return (uchar*)key; } @@ -561,7 +561,7 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c { struct promise* p = future_to_promise(f); unsigned int len = 0; - uchar* key = get_key_by_cert(origin_cert, keyring_id, &len); + uchar* key = get_key_by_cert(origin_cert, keyring_id, &len, is_cert_valid); if(key == NULL) { promise_failed(p, FUTURE_ERROR_EXCEPTION, "get hash key by_cert failed");