1010
1111#include "../src/proxy_protocol.h"
1212
13+ /* Self-signed EC (prime256v1) X.509 DER certificate, CN=test */
14+ static const uint8_t client_cert_der [] = {
15+ 0x30 , 0x82 , 0x01 , 0x72 , 0x30 , 0x82 , 0x01 , 0x19 , 0xa0 , 0x03 , 0x02 , 0x01 ,
16+ 0x02 , 0x02 , 0x14 , 0x27 , 0xd1 , 0xb7 , 0x26 , 0x8d , 0xd6 , 0x95 , 0x5b , 0xda ,
17+ 0xe3 , 0x58 , 0x8d , 0x19 , 0xbe , 0x88 , 0x84 , 0x32 , 0xcc , 0x62 , 0xea , 0x30 ,
18+ 0x0a , 0x06 , 0x08 , 0x2a , 0x86 , 0x48 , 0xce , 0x3d , 0x04 , 0x03 , 0x02 , 0x30 ,
19+ 0x0f , 0x31 , 0x0d , 0x30 , 0x0b , 0x06 , 0x03 , 0x55 , 0x04 , 0x03 , 0x0c , 0x04 ,
20+ 0x74 , 0x65 , 0x73 , 0x74 , 0x30 , 0x1e , 0x17 , 0x0d , 0x32 , 0x36 , 0x30 , 0x33 ,
21+ 0x31 , 0x31 , 0x31 , 0x34 , 0x34 , 0x36 , 0x34 , 0x39 , 0x5a , 0x17 , 0x0d , 0x33 ,
22+ 0x36 , 0x30 , 0x33 , 0x30 , 0x38 , 0x31 , 0x34 , 0x34 , 0x36 , 0x34 , 0x39 , 0x5a ,
23+ 0x30 , 0x0f , 0x31 , 0x0d , 0x30 , 0x0b , 0x06 , 0x03 , 0x55 , 0x04 , 0x03 , 0x0c ,
24+ 0x04 , 0x74 , 0x65 , 0x73 , 0x74 , 0x30 , 0x59 , 0x30 , 0x13 , 0x06 , 0x07 , 0x2a ,
25+ 0x86 , 0x48 , 0xce , 0x3d , 0x02 , 0x01 , 0x06 , 0x08 , 0x2a , 0x86 , 0x48 , 0xce ,
26+ 0x3d , 0x03 , 0x01 , 0x07 , 0x03 , 0x42 , 0x00 , 0x04 , 0x88 , 0x7b , 0xd1 , 0x60 ,
27+ 0x92 , 0x37 , 0x00 , 0x86 , 0x8c , 0x3d , 0x06 , 0x42 , 0xf4 , 0x1b , 0x9f , 0x27 ,
28+ 0x9e , 0xca , 0x74 , 0xc5 , 0xdb , 0xfd , 0x6f , 0x82 , 0x39 , 0x61 , 0x70 , 0xb9 ,
29+ 0x0b , 0xe8 , 0x14 , 0x07 , 0xc6 , 0x30 , 0xea , 0xd8 , 0xbb , 0x01 , 0x05 , 0x5f ,
30+ 0x07 , 0x6a , 0xe8 , 0x1f , 0x2c , 0x4b , 0x43 , 0x8f , 0x4d , 0x87 , 0xa1 , 0xad ,
31+ 0xc6 , 0x19 , 0x05 , 0xae , 0x2b , 0x09 , 0x60 , 0x55 , 0x00 , 0x4a , 0xe7 , 0xb4 ,
32+ 0xa3 , 0x53 , 0x30 , 0x51 , 0x30 , 0x1d , 0x06 , 0x03 , 0x55 , 0x1d , 0x0e , 0x04 ,
33+ 0x16 , 0x04 , 0x14 , 0xf9 , 0x84 , 0xb4 , 0x02 , 0xba , 0x3c , 0xa8 , 0xa9 , 0x19 ,
34+ 0x86 , 0x9e , 0x3c , 0xe6 , 0x77 , 0x79 , 0x39 , 0x9a , 0x7f , 0x1e , 0x53 , 0x30 ,
35+ 0x1f , 0x06 , 0x03 , 0x55 , 0x1d , 0x23 , 0x04 , 0x18 , 0x30 , 0x16 , 0x80 , 0x14 ,
36+ 0xf9 , 0x84 , 0xb4 , 0x02 , 0xba , 0x3c , 0xa8 , 0xa9 , 0x19 , 0x86 , 0x9e , 0x3c ,
37+ 0xe6 , 0x77 , 0x79 , 0x39 , 0x9a , 0x7f , 0x1e , 0x53 , 0x30 , 0x0f , 0x06 , 0x03 ,
38+ 0x55 , 0x1d , 0x13 , 0x01 , 0x01 , 0xff , 0x04 , 0x05 , 0x30 , 0x03 , 0x01 , 0x01 ,
39+ 0xff , 0x30 , 0x0a , 0x06 , 0x08 , 0x2a , 0x86 , 0x48 , 0xce , 0x3d , 0x04 , 0x03 ,
40+ 0x02 , 0x03 , 0x47 , 0x00 , 0x30 , 0x44 , 0x02 , 0x20 , 0x2a , 0x7e , 0xf8 , 0xf6 ,
41+ 0x4c , 0x99 , 0x27 , 0x70 , 0x24 , 0x9b , 0x51 , 0x8f , 0x29 , 0x23 , 0x9b , 0x41 ,
42+ 0x01 , 0x93 , 0x0f , 0x77 , 0x84 , 0xba , 0x08 , 0x34 , 0xee , 0x23 , 0xa6 , 0xaf ,
43+ 0xe5 , 0xdc , 0x7d , 0xf3 , 0x02 , 0x20 , 0x53 , 0xf2 , 0x42 , 0xd6 , 0xab , 0xca ,
44+ 0x9a , 0x66 , 0xfe , 0x3e , 0x49 , 0x77 , 0xf6 , 0xe4 , 0xea , 0xcb , 0xff , 0xde ,
45+ 0x1e , 0xf7 , 0x2b , 0x97 , 0x40 , 0x99 , 0xde , 0x2e , 0x9b , 0x15 , 0x5c , 0x87 ,
46+ 0xb7 , 0x7c
47+ };
48+
1349int main (void )
1450{
1551 int32_t error = ERR_NULL ;
@@ -84,7 +120,7 @@ int main(void)
84120 pp_info_in_v2 .pp2_info .pp2_ssl_info .cert_verified = 1 ;
85121 /* Add SSL TLVs */
86122 /* IMPORTANT: Always clear the pp_info to be passed in pp_create_hdr() because TLVs are allocated in heap. Otherwise memory will be leaked */
87- if (!pp_info_add_ssl (& pp_info_in_v2 , "TLSv1.2" , "ECDHE-RSA-AES128-GCM-SHA256" , "SHA256" , "RSA2048" , (const uint8_t * ) "example.com" , 11 ))
123+ if (!pp_info_add_ssl (& pp_info_in_v2 , "TLSv1.2" , "ECDHE-RSA-AES128-GCM-SHA256" , "SHA256" , "RSA2048" , "secp256r1" , "rsa_pss_rsae_sha256" , (const uint8_t * ) "example.com" , 11 , client_cert_der , sizeof ( client_cert_der ) ))
88124 {
89125 fprintf (stderr , "pp_info_add_ssl() failed\n" );
90126 pp_info_clear (& pp_info_in_v2 );
@@ -120,10 +156,11 @@ int main(void)
120156 }
121157 else
122158 {
123- uint16_t length , cn_length ;
159+ uint16_t length , cn_length , client_cert_length ;
124160 uint32_t linkid ;
125161 const uint8_t * azure_linkid = pp_info_get_azure_linkid (& pp_info_out , & length );
126162 const uint8_t * cn = pp_info_get_ssl_cn (& pp_info_out , & cn_length );
163+ const uint8_t * client_cert = pp_info_get_ssl_client_cert (& pp_info_out , & client_cert_length );
127164 memcpy (& linkid , azure_linkid , length );
128165 printf ("%d bytes PROXY protocol header:\n"
129166 "\tAzure Link ID: %u\n"
@@ -132,7 +169,10 @@ int main(void)
132169 "\tSSL cipher: %s\n"
133170 "\tSSL sig_alg: %s\n"
134171 "\tSSL key_alg: %s\n"
172+ "\tSSL group: %s\n"
173+ "\tSSL sig_scheme: %s\n"
135174 "\tSSL CN: %.*s\n"
175+ "\tSSL client_cert: %s\n"
136176 "\t%s %s %hu %hu\n" ,
137177 rc , linkid ,
138178 /* In case CRC32c is wrong then rc < 0 => pp_strerror(rc) at previous block will print the error */
@@ -141,7 +181,10 @@ int main(void)
141181 pp_info_get_ssl_cipher (& pp_info_out , & length ),
142182 pp_info_get_ssl_sig_alg (& pp_info_out , & length ),
143183 pp_info_get_ssl_key_alg (& pp_info_out , & length ),
184+ pp_info_get_ssl_group (& pp_info_out , & length ),
185+ pp_info_get_ssl_sig_scheme (& pp_info_out , & length ),
144186 cn_length , cn ,
187+ client_cert ? "present" : "not present" ,
145188 pp_info_out .src_addr , pp_info_out .dst_addr ,
146189 pp_info_out .src_port , pp_info_out .dst_port );
147190 }
0 commit comments