well srikanth there is a server code in the apps of the ssl distribution try looking at the file s_server.c should help u
The thing also try getting the errors from the SSL library there is something called SSL_get_Error takes 2 parameters and ERR_error_string which will give u the string reprsentation it will give a proper error message check the status of the calls u are making each of these can fail -SIGTERM amit PS i assume that uhave done SSL_library_init() [EMAIL PROTECTED] wrote: > >Hi all, >I am trying to write a server that coneects using winsock and talks to a client >using openssl methods. >Could anybody tell me the actual flow of writing the server? >I have written the following code, but it always fails at SSL_accept. > > m_SSLMethod = TLSv1_server_method(); > m_SSLContext = SSL_CTX_new(m_SSLMethod); > iResult = SSL_CTX_use_certificate_chain_file(m_SSLContext, file); > SSL_CTX_set_default_passwd_cb(m_SSLContext,password_cb); > iResult = SSL_CTX_use_PrivateKey_file(m_SSLContext, file,SSL_FILETYPE_PEM); > //file is the name of the key file > iResult = SSL_CTX_load_verify_locations(m_SSLContext, cert,0); //cert is >the certificate file name > > here comes the socket creation, bind and listen > > while(1) > { > m_Socket = accept(m_Socket,0,0); > sbio=BIO_new_socket(m_Socket,BIO_NOCLOSE); > m_SSLConnection = SSL_new(m_SSLContext); > SSL_set_bio(m_SSLConnection,sbio,sbio); > iResult = SSL_accept(m_SSLConnection); > it always fails here returning -1. > iResult = SSL_read(m_SSLConnection, szBuff, sizeof(szBuff)-1); > } > >Please tell me what is wrong/missing/additional in the code. >Is the way of using the key and certificate right? > >thanks in advance >Sri > > > > > > > > > > >--------------------------------------------------------------------------------------------------------------------------- > >This email message (including any attachment) is confidential and may be legally >privileged. >It is intended solely for the addressee. If you are not the addressee, you may >not disclose it, copy it, distribute it or take or omit to take any action on >foot of it. Any such act or omission is prohibited and may be unlawful. This >message (including any attachment) is transmitted for discussion purposes only. >It is protected by copyright laws and it has no other legal or contractual >standing. > > > > >********************************************************************** >This email and any files transmitted with it are confidential and >intended solely for the use of the individual or entity to whom they >are addressed. If you have received this email in error please notify >the system manager. > >This footnote also confirms that this email message has been swept by >MIMEsweeper for the presence of computer viruses. > >www.Kindlesystems.com >********************************************************************** >______________________________________________________________________ >OpenSSL Project http://www.openssl.org >User Support Mailing List [EMAIL PROTECTED] >Automated List Manager [EMAIL PROTECTED] > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]