You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2012/12/04 21:30:58 UTC

[jira] [Updated] (AMQCPP-444) Exception too general

     [ https://issues.apache.org/jira/browse/AMQCPP-444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish updated AMQCPP-444:
--------------------------------

    Description: 
In decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp the function OpenSSLSocket::write after the call to SSL_write, the switch statement goes across possible errors and throws exceptions if necessary, but there are many more errors that what is checked for.  My program was getting SSL_ERROR_SYSCALL, but was just being thrown as the default.

I added some code, its not the best messages, but you can change that

{noformat}

switch( SSL_get_error( this->parameters->getSSL(), written ) ) {
                case SSL_ERROR_NONE:
                    offset += written;
                    remaining -= written;
                    break;
                case SSL_ERROR_ZERO_RETURN:
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The connection was broken unexpectedly." );
                case SSL_ERROR_WANT_WRITE:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The exception was WANT_WRITE." );
                    break;
                case SSL_ERROR_WANT_READ:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The exception was WANT_READ." );
                    break;
                case SSL_ERROR_WANT_X509_LOOKUP:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The Exception was WANT_X509_LOOKUP." );
                    break;
                case SSL_ERROR_SYSCALL:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    fprintf(stderr, "errno=%d", errno);
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The Exception was ERROR_SYSCALL. ret=%d", written ); 
                    break;
                case SSL_ERROR_SSL:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The Exception was general ERROR_SSL" );
                    break;
                default:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw OpenSSLSocketException( __FILE__, __LINE__, "Default case, I cannot happen now" );
                    break;
            }

{noformat}

You also need to include errno.h and openssl/err.h for some for some of the messages I was printing.
Thanks and please add something similar to the trunk if no objection.

  was:
In decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp the function OpenSSLSocket::write after the call to SSL_write, the switch statement goes across possible errors and throws exceptions if necessary, but there are many more errors that what is checked for.  My program was getting SSL_ERROR_SYSCALL, but was just being thrown as the default.

I added some code, its not the best messages, but you can change that

switch( SSL_get_error( this->parameters->getSSL(), written ) ) {
                case SSL_ERROR_NONE:
                    offset += written;
                    remaining -= written;
                    break;
                case SSL_ERROR_ZERO_RETURN:
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The connection was broken unexpectedly." );
                case SSL_ERROR_WANT_WRITE:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The exception was WANT_WRITE." );
                    break;
                case SSL_ERROR_WANT_READ:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The exception was WANT_READ." );
                    break;
                case SSL_ERROR_WANT_X509_LOOKUP:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The Exception was WANT_X509_LOOKUP." );
                    break;
                case SSL_ERROR_SYSCALL:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    fprintf(stderr, "errno=%d", errno);
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The Exception was ERROR_SYSCALL. ret=%d", written ); 
                    break;
                case SSL_ERROR_SSL:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw SocketException(
                        __FILE__, __LINE__,
                        "The Exception was general ERROR_SSL" );
                    break;
                default:
                    fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
                    throw OpenSSLSocketException( __FILE__, __LINE__, "Default case, I cannot happen now" );
                    break;
            }


You also need to include errno.h and openssl/err.h for some for some of the messages I was printing.
Thanks and please add something similar to the trunk if no objection.

    
> Exception too general
> ---------------------
>
>                 Key: AMQCPP-444
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-444
>             Project: ActiveMQ C++ Client
>          Issue Type: Improvement
>          Components: Decaf
>    Affects Versions: 3.4.5
>         Environment: HPUX 11.31 but all
>            Reporter: Jeffrey B
>            Assignee: Timothy Bish
>            Priority: Minor
>              Labels: exception-reporting, ssl
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> In decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp the function OpenSSLSocket::write after the call to SSL_write, the switch statement goes across possible errors and throws exceptions if necessary, but there are many more errors that what is checked for.  My program was getting SSL_ERROR_SYSCALL, but was just being thrown as the default.
> I added some code, its not the best messages, but you can change that
> {noformat}
> switch( SSL_get_error( this->parameters->getSSL(), written ) ) {
>                 case SSL_ERROR_NONE:
>                     offset += written;
>                     remaining -= written;
>                     break;
>                 case SSL_ERROR_ZERO_RETURN:
>                     throw SocketException(
>                         __FILE__, __LINE__,
>                         "The connection was broken unexpectedly." );
>                 case SSL_ERROR_WANT_WRITE:
>                     fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
>                     throw SocketException(
>                         __FILE__, __LINE__,
>                         "The exception was WANT_WRITE." );
>                     break;
>                 case SSL_ERROR_WANT_READ:
>                     fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
>                     throw SocketException(
>                         __FILE__, __LINE__,
>                         "The exception was WANT_READ." );
>                     break;
>                 case SSL_ERROR_WANT_X509_LOOKUP:
>                     fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
>                     throw SocketException(
>                         __FILE__, __LINE__,
>                         "The Exception was WANT_X509_LOOKUP." );
>                     break;
>                 case SSL_ERROR_SYSCALL:
>                     fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
>                     fprintf(stderr, "errno=%d", errno);
>                     throw SocketException(
>                         __FILE__, __LINE__,
>                         "The Exception was ERROR_SYSCALL. ret=%d", written ); 
>                     break;
>                 case SSL_ERROR_SSL:
>                     fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
>                     throw SocketException(
>                         __FILE__, __LINE__,
>                         "The Exception was general ERROR_SSL" );
>                     break;
>                 default:
>                     fprintf(stderr, "Err_get_error()=%d\n", ERR_get_error());
>                     throw OpenSSLSocketException( __FILE__, __LINE__, "Default case, I cannot happen now" );
>                     break;
>             }
> {noformat}
> You also need to include errno.h and openssl/err.h for some for some of the messages I was printing.
> Thanks and please add something similar to the trunk if no objection.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira