]> git.kaiwu.me - nginx.git/commitdiff
SSL: return temporary RSA key only when the key length matches.
authorPiotr Sikora <piotr@cloudflare.com>
Sun, 6 Jul 2014 23:41:13 +0000 (16:41 -0700)
committerPiotr Sikora <piotr@cloudflare.com>
Sun, 6 Jul 2014 23:41:13 +0000 (16:41 -0700)
This change is mostly cosmetic, because in practice this callback
is used only for 512-bit RSA keys.

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
src/event/ngx_event_openssl.c

index 50691ade7045002371963fa025046424eb1f4fcd..46934b2f6007937428066919acacaa0a07294dcb 100644 (file)
@@ -652,10 +652,12 @@ ngx_ssl_rsa512_key_callback(ngx_ssl_conn_t *ssl_conn, int is_export,
 {
     static RSA  *key;
 
-    if (key_length == 512) {
-        if (key == NULL) {
-            key = RSA_generate_key(512, RSA_F4, NULL, NULL);
-        }
+    if (key_length != 512) {
+        return NULL;
+    }
+
+    if (key == NULL) {
+        key = RSA_generate_key(512, RSA_F4, NULL, NULL);
     }
 
     return key;