Enable the upper layer protocol to specify the SNI peername. This avoids the need for tlshd to use a DNS lookup, which can return a hostname that doesn't match the incoming certificate's SubjectName.
Unified · Split
| @@ -68,6 +68,9 @@ attribute-sets: · 67 unmodified lines | |||
| 68 | type: nest | 68 | type: nest |
| 69 | nested-attributes: x509 | 69 | nested-attributes: x509 |
| 70 | multi-attr: true | 70 | multi-attr: true |
| 71 | - | ||
| 72 | name: peername | ||
| 73 | type: string | ||
| 71 | - | 74 | - |
| 72 | name: done | 75 | name: done |
| 73 | attributes: | 76 | attributes: |
| @@ -105,6 +108,7 @@ operations: · 31 unmodified lines | |||
| 105 | - auth-mode | 108 | - auth-mode |
| 106 | - peer-identity | 109 | - peer-identity |
| 107 | - certificate | 110 | - certificate |
| 111 | - peername | ||
| 108 | - | 112 | - |
| 109 | name: done | 113 | name: done |
| 110 | doc: Handler reports handshake completion | 114 | doc: Handler reports handshake completion |
| @@ -53,6 +53,7 @@ fills in a structure that contains the parameters of the request: · 52 unmodified lines | |||
| 53 | struct socket *ta_sock; | 53 | struct socket *ta_sock; |
| 54 | tls_done_func_t ta_done; | 54 | tls_done_func_t ta_done; |
| 55 | void *ta_data; | 55 | void *ta_data; |
| 56 | const char *ta_peername; | ||
| 56 | unsigned int ta_timeout_ms; | 57 | unsigned int ta_timeout_ms; |
| 57 | key_serial_t ta_keyring; | 58 | key_serial_t ta_keyring; |
| 58 | key_serial_t ta_my_cert; | 59 | key_serial_t ta_my_cert; |
| @@ -71,6 +72,10 @@ instantiated a struct file in sock->file. · 12 unmodified lines | |||
| 71 | has completed. Further explanation of this function is in the "Handshake | 72 | has completed. Further explanation of this function is in the "Handshake |
| 72 | Completion" sesction below. | 73 | Completion" sesction below. |
| 73 | 74 | ||
| 75 | The consumer can provide a NUL-terminated hostname in the @ta_peername | ||
| 76 | field that is sent as part of ClientHello. If no peername is provided, | ||
| 77 | the DNS hostname associated with the server's IP address is used instead. | ||
| 78 | |||
| 74 | The consumer can fill in the @ta_timeout_ms field to force the servicing | 79 | The consumer can fill in the @ta_timeout_ms field to force the servicing |
| 75 | handshake agent to exit after a number of milliseconds. This enables the | 80 | handshake agent to exit after a number of milliseconds. This enables the |
| 76 | socket to be fully closed once both the kernel and the handshake agent | 81 | socket to be fully closed once both the kernel and the handshake agent |
| @@ -24,6 +24,7 @@ struct tls_handshake_args { · 23 unmodified lines | |||
| 24 | struct socket *ta_sock; | 24 | struct socket *ta_sock; |
| 25 | tls_done_func_t ta_done; | 25 | tls_done_func_t ta_done; |
| 26 | void *ta_data; | 26 | void *ta_data; |
| 27 | const char *ta_peername; | ||
| 27 | unsigned int ta_timeout_ms; | 28 | unsigned int ta_timeout_ms; |
| 28 | key_serial_t ta_keyring; | 29 | key_serial_t ta_keyring; |
| 29 | key_serial_t ta_my_cert; | 30 | key_serial_t ta_my_cert; |
| @@ -44,6 +44,7 @@ enum { · 43 unmodified lines | |||
| 44 | HANDSHAKE_A_ACCEPT_AUTH_MODE, | 44 | HANDSHAKE_A_ACCEPT_AUTH_MODE, |
| 45 | HANDSHAKE_A_ACCEPT_PEER_IDENTITY, | 45 | HANDSHAKE_A_ACCEPT_PEER_IDENTITY, |
| 46 | HANDSHAKE_A_ACCEPT_CERTIFICATE, | 46 | HANDSHAKE_A_ACCEPT_CERTIFICATE, |
| 47 | HANDSHAKE_A_ACCEPT_PEERNAME, | ||
| 47 | 48 | ||
| 48 | __HANDSHAKE_A_ACCEPT_MAX, | 49 | __HANDSHAKE_A_ACCEPT_MAX, |
| 49 | HANDSHAKE_A_ACCEPT_MAX = (__HANDSHAKE_A_ACCEPT_MAX - 1) | 50 | HANDSHAKE_A_ACCEPT_MAX = (__HANDSHAKE_A_ACCEPT_MAX - 1) |
| @@ -31,6 +31,7 @@ struct tls_handshake_req { · 30 unmodified lines | |||
| 31 | int th_type; | 31 | int th_type; |
| 32 | unsigned int th_timeout_ms; | 32 | unsigned int th_timeout_ms; |
| 33 | int th_auth_mode; | 33 | int th_auth_mode; |
| 34 | const char *th_peername; | ||
| 34 | key_serial_t th_keyring; | 35 | key_serial_t th_keyring; |
| 35 | key_serial_t th_certificate; | 36 | key_serial_t th_certificate; |
| 36 | key_serial_t th_privkey; | 37 | key_serial_t th_privkey; |
| @@ -48,6 +49,7 @@ tls_handshake_req_init(struct handshake_req *req, · 11 unmodified lines | |||
| 48 | treq->th_timeout_ms = args->ta_timeout_ms; | 49 | treq->th_timeout_ms = args->ta_timeout_ms; |
| 49 | treq->th_consumer_done = args->ta_done; | 50 | treq->th_consumer_done = args->ta_done; |
| 50 | treq->th_consumer_data = args->ta_data; | 51 | treq->th_consumer_data = args->ta_data; |
| 52 | treq->th_peername = args->ta_peername; | ||
| 51 | treq->th_keyring = args->ta_keyring; | 53 | treq->th_keyring = args->ta_keyring; |
| 52 | treq->th_num_peerids = 0; | 54 | treq->th_num_peerids = 0; |
| 53 | treq->th_certificate = TLS_NO_CERT; | 55 | treq->th_certificate = TLS_NO_CERT; |
| @@ -214,6 +216,12 @@ static int tls_handshake_accept(struct handshake_req *req, · 160 unmodified lines | |||
| 214 | ret = nla_put_u32(msg, HANDSHAKE_A_ACCEPT_MESSAGE_TYPE, treq->th_type); | 216 | ret = nla_put_u32(msg, HANDSHAKE_A_ACCEPT_MESSAGE_TYPE, treq->th_type); |
| 215 | if (ret < 0) | 217 | if (ret < 0) |
| 216 | goto out_cancel; | 218 | goto out_cancel; |
| 219 | if (treq->th_peername) { | ||
| 220 | ret = nla_put_string(msg, HANDSHAKE_A_ACCEPT_PEERNAME, | ||
| 221 | treq->th_peername); | ||
| 222 | if (ret < 0) | ||
| 223 | goto out_cancel; | ||
| 224 | } | ||
| 217 | if (treq->th_timeout_ms) { | 225 | if (treq->th_timeout_ms) { |
| 218 | ret = nla_put_u32(msg, HANDSHAKE_A_ACCEPT_TIMEOUT, treq->th_timeout_ms); | 226 | ret = nla_put_u32(msg, HANDSHAKE_A_ACCEPT_TIMEOUT, treq->th_timeout_ms); |
| 219 | if (ret < 0) | 227 | if (ret < 0) |