cryptPopData() returns error -16 with TLS
Tamim <[email protected]>
| Newsgroups | gmane.comp.encryption.cryptlib |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I'm trying to establish a TLS session using the current version of cryptlib
under MSVS C++ Express 2010/Windows 7 as a client against a server application
which is TLS-enabled via stunnel! Sending messages using cryptPushData() seam to
work fine (according to the log entries of the server application) but
cryptPopData() returns -16 (CRYPT_INTERNAL_ERROR). The values of the attributes
CRYPT_ATTRIBUTE_ERRORTYPE and CRYPT_ATTRIBUTE_ERRORLOCUS after the error has
occured are 0. An attempt to get the value of the attribute
CRYPT_ATTRIBUTE_ERRORMESSAGE returns with the error code -43.
Here is the code:
CRYPT_SESSION cryptSession;
status = cryptInit();
if ( status == CRYPT_OK ) {
/* Create the session */
status = cryptCreateSession( &cryptSession, CRYPT_UNUSED, CRYPT_SESSION_SSL );
}
if ( status == CRYPT_OK ) {
/* Add server name */
int len = strlen(serverName);
status = cryptSetAttributeString( cryptSession, CRYPT_SESSINFO_SERVER_NAME,
serverName, len );
}
if ( status == CRYPT_OK ) {
/* Add server port */
status = cryptSetAttribute( cryptSession, CRYPT_SESSINFO_SERVER_PORT,
serverPort );
}
if ( status == CRYPT_OK ) {
/* Activate session */
status = cryptSetAttribute( cryptSession, CRYPT_SESSINFO_ACTIVE, 1 );
}
if ( status == CRYPT_OK ) {
/* Exchange data with the server */
int bytesCopied = 0;
int bufferSize = 256;
char* buffer = new char[bufferSize + 1];
/* Discard initial response */
status = cryptPopData( cryptSession, buffer, bufferSize, &bytesCopied );
if ( status == CRYPT_OK ) {
printf("\nGot data: %s", buffer);
}
...
What am I doing wrong? Any help would be very much appreciated.
Tamim
_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.