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7MhSQROBtLJf31s " 18 "jaIVh8+CsM0TE3jbv2w1b4+tARFoJitUic71eOEWhgJ+Fm0yGAlUhmIHPx5SzehG " 19 "waDrfaSp6gWRNO+5W0Y55RVCuEMSmPt783vVum5f+rkdhaowYGTW6FvmXoAdP/a1 " 20 "Ryl3ighzGfrgiAHpfftj1u1HCmFvMHgdt16/wSmoHRo0vKSv+/hKNAhr+USsyXaw " 21 "KHU3w4paqT+ph/8uKPI1 " 22 "-----END CERTIFICATE----- " 23 ; 24 25 26 static unsigned char private_pem[]="-----BEGIN RSA PRIVATE KEY----- " 27 "MIIEowIBAAKCAQEAvHnq/oDnK3CMfuO7BGpE/e5DOMRgaRBgzbnO/WKZ0y2yj3x9 " 28 "lJwgDepjkekSxl8ra6cLUjueCy0OgltJmqTUGS3GHOR5bXMhTPq3r7Mm8Y7t/biW " 29 "dbUxryoD7h3PI5h4gg81/7qqiU1fQOvkuI3a63uNl+qQLTCu2kXY1rkWN2OTe/G0 " 30 "d6SMD6OaYUlb1O0p2FOi22dtKD6tLEDJrOoHyA1U2PDnmtq8g/wiP8JuC2Y7InN0 " 31 "AZi8Lu3RI/DqIJSv0mODOSU6MtMYgPSVWdTv6jucfg5T9CObP8lBhmJq4cO3AlLh " 32 "PxHm9FOB8tkT1bFs2XMmCyJbGf8FaDR1GreGMQIDAQABAoIBADEYFNUsYIrZK0+W " 33 "JE3XHJeEa7Aqvu4/HOgZoUgxWd4/RgbIJ7IBJPxa9Iq6SnCvs5C8F1/ZNaa1mtTr " 34 "0HVev/y7BqLaBKM03RS/Lf+vS9KaJ3XykgahJwr4h8OLsjwUaDeAnNE7H1bad5hi " 35 "mdZU5RR3v381005iIvmqPfxYg+fzLi7bWWoBH063Wsrx8paznTv1hpeDkF4Xt4n3 " 36 "2wktEasxdobmzodJ5gMJoBpVEQ+KRBCrKimCxyt3ZjWlRNC3iTa9mKlAQMBdGNqk " 37 "OkiUvLCzVNMcndHCCe42Bo5xqxDq9P70aLgFQzf0jWghzoYlpZjqqehqLdWvqzQT " 38 "eHgXjc0CgYEA8b0IBNoQv/Gion6Sj8E3cF2Zj82Gg/3sBkRBxZwwyeXCwa3MASOr " 39 "RV1d/kD6J8Crjp1pGwGsqeA099LzvVKXfZ0jx8CR3bJ3wwgwOn+i2kj1GCott6DG " 40 "58t5+hVijoFJITLkEY0zcvS2gtnDL/EIbPdBNk4oRTynJhqKquycizMCgYEAx5h4 " 41 "OIKuXawz5xmxqRTFhDgluU0o/9CRwvBX1pitcSrAPTwhPBenPEqwY4y71js0B212 " 42 "hInbp80GxiK0G03mu50s5/O17XIB9+Jp+VW/vAVrcdSod0eIQS36a0pOUDLcLoSQ " 43 "17JCVtPfcG3PkC9mC539DCt3sJUVhApV0WKESQsCgYEA672jX0/lO7oCFyMF/Gi5 " 44 "jrvIsEMGphtvG6Fe3r31mj6VEdlR8957/LYTnopxKWksJHT/ddXJMxSxsugmx/8O " 45 "OvKOXRM/bIrJXgnTNokYIHU7hyhC0ytYLd3xgt9t8HjF/zkozrD7dmSMw8hnH46X " 46 "3+Oz1aicfwCqJG+HwS3jb58CgYAixVwENDfeF7a/Bsndc8HpA8MGofuHfTU3aZlT " 47 "yCtG8LSmtkfv6Qr4ROavoP/EFXI97QLdmgqLE/ufHsKTkyGkA4CkM9+4qsjO/0GI " 48 "7zhEsAkEvpBOn0aMXE8oy7wS2pli/TMicGqAJ87gDjE/pBI56d8AdL4YJBCofQhw " 49 "PqJe+wKBgHPpbMNxYofSIf9vkaE/ukg00DFrNO7MX7Q6FOQG3omUQ9456hRtySvA " 50 "PuuuwX7qWnoiauwJ+G4Gs+7lX9MMGjhlpHX2qPnb8YvliFXuoDqG7XwCtLmhXM3a " 51 "0ycSMi0AYO6qQ5F2kIcHewOrghdK5PsT7Xj22ZmkS8/o3WdV6h1B " 52 "-----END RSA PRIVATE KEY----- "; 53 54 55 EVP_PKEY *pEvp_pkey = NULL; 56 X509 *pX509 = NULL; 57 58 BIO *publicbio = BIO_new_mem_buf (public_pem, -1); 59 assert (publicbio); 60 PEM_read_bio_X509 (publicbio, &pX509, NULL, 0); 61 BIO_free (publicbio); 62 63 BIO *privatebio = BIO_new_mem_buf (private_pem, -1); 64 assert (privatebio); 65 PEM_read_bio_PrivateKey (privatebio, &pEvp_pkey, 0, 0); 66 BIO_free (privatebio); 67 68 int e; 69 e = SSL_CTX_use_certificate (ctx, pX509); 70 if (e <= 0) ERR_print_errors_fp(stderr); 71 assert (e > 0); 72 73 e = SSL_CTX_use_PrivateKey (ctx, pEvp_pkey); 74 if (e <= 0) ERR_print_errors_fp(stderr); 75 assert (e > 0);