C でコーディングされた SSL サーバーで、ブラウザー ヘッダーをキャプチャしようとしています。サーバーは Linux マシンのポート 443 で実行され、Windows\System32\drivers\etc\ のホスト ファイルにサーバー名を追加してホスト名を解決しています。ホストは SSL ハンドシェイクは成功しているように見えますが、SSL_read は失敗します。助けてください。また、以下のサーバー情報出力を見つけてください。
ssl = SSL_new(ctx);
RETURN_NULL(ssl);
if(SSL_set_fd(ssl, client_s)<0)
printf("\n error in assigning socket to SSL:");
else
printf("\n The socket has been assigned to SSL Structure");
/* Perform SSL Handshake on the SSL server */
err = SSL_accept(ssl);
printf("\n Value of err is %d",err);
RETURN_ERR(err,"SSL_accept");
if(err==1)
printf("\n The ssl connection/Handshake has been successful");
else
printf("\n The ssl connection was not successful");
/* Informational output (optional) */
printf("\n SSL connection using %s\n", SSL_get_cipher (ssl));
/*receive the data from the client*/
//err = SSL_accept(ssl);
while(i<5)
{
err = SSL_read(ssl, in_buf, strlen(in_buf));
printf("\n value of err is %d",err);
RETURN_ERR(err,"SSL_read");
printf("\n The details from the server is\n: %s,\n Bytes Read : %d",in_buf,err);
if(err<0)
printf("\n Not Successfully received clients information");
i++;
}
err = SSL_shutdown(ssl);
/* Terminate communication on a socket */
err = close(server_s);
/* Free the SSL structure */
SSL_free(ssl);
/* Free the SSL_CTX structure */
SSL_CTX_free(ctx);
return(0);
}
そして、IE(url: https://myserver.com/test2.jpg ) を使用して取得した上記のコードの出力は次のとおりです。
root@unnidevelubuntu:/programs# gcc -lssl trial11.c -o trial11
root@unnidevelubuntu:/programs# ./trial11
Available ciphers and digests has been registered :
New SSL_CTX object created successfully :
Enter PEM pass phrase:
The key & Certificate has been loaded successfully :
Server is waiting for a TCP/IP Connection :
private key matches the certificate public key :server is ready ...
Connection from 192.168.0.15, port 56969
a new client arrives ...
The socket has been assigned to SSL Structure
Value of err is 1
The ssl connection/Handshake has been successful
SSL connection using RC4-SHA
value of err is 0
The details from the server is
: ,
Bytes Read : 0
value of err is 0
The details from the server is
: ,
Bytes Read : 0
value of err is 0
The details from the server is
: ,
Bytes Read : 0
value of err is 0
The details from the server is