----------------------------------------------------------------------------*/
| 138 | |
| 139 | /*----------------------------------------------------------------------------*/ |
| 140 | int RunHttpsThread(void) |
| 141 | { |
| 142 | int sockfd, new_fd ,ret,client_sockfd,client_sslsockfd; |
| 143 | socklen_t len; |
| 144 | int epoll_fd; |
| 145 | int nfds; |
| 146 | struct sockaddr_in my_addr, their_addr; |
| 147 | struct sockaddr_in remote_addr; |
| 148 | struct epoll_event ev; |
| 149 | struct epoll_event events[MAX_EVENTS]; |
| 150 | unsigned int myport, lisnum; |
| 151 | char buf[MAXBUF + 1]; |
| 152 | SSL_CTX *ctx; |
| 153 | int opt_val = 1; |
| 154 | int sin_size,r,err; |
| 155 | SSL *ssl; |
| 156 | BIO *bio_err = NULL; |
| 157 | int result =0; |
| 158 | int do_sslaccept = 0; |
| 159 | |
| 160 | ans_mod_init(); |
| 161 | |
| 162 | myport = 7838; |
| 163 | lisnum = 2048; |
| 164 | |
| 165 | /* LIBSSL init */ |
| 166 | SSL_library_init(); |
| 167 | /* Load all SSL algorithm*/ |
| 168 | OpenSSL_add_all_algorithms(); |
| 169 | /*Load all SSL error*/ |
| 170 | SSL_load_error_strings(); |
| 171 | /* Produce a SSL CTX in SSL V2 and V3 standards compliant way */ |
| 172 | ctx = SSL_CTX_new(SSLv23_server_method()); |
| 173 | |
| 174 | if (ctx == NULL) |
| 175 | { |
| 176 | exit(1); |
| 177 | } |
| 178 | /* Require calibration certificate */ |
| 179 | /*Can choose not to calibration*/ |
| 180 | #ifdef LOAD_CERTIFICATE |
| 181 | SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL); |
| 182 | #endif |
| 183 | /*Load the CA's certificate*/ |
| 184 | if(!SSL_CTX_load_verify_locations(ctx, "cacert.cer", NULL)) |
| 185 | { |
| 186 | printf("loda caverify fail\n"); |
| 187 | } |
| 188 | |
| 189 | /*Loading their own certificates */ |
| 190 | if (SSL_CTX_use_certificate_file(ctx, "server.cer", SSL_FILETYPE_PEM) <= 0) |
| 191 | { |
| 192 | printf("loda certificate fail\n"); |
| 193 | } |
| 194 | |
| 195 | /*Loading their own key */ |
| 196 | if (SSL_CTX_use_PrivateKey_file(ctx, "server.key", SSL_FILETYPE_PEM) <= 0) |
| 197 | { |
no test coverage detected