Problem with getting error description after SSL_CTX_new returned NULL - c++

I am very new to SSL , Actually I would say I know nothing about it.
I am using the method "SSL_CTX_new" to create an SSL_CTX object. The method returns null.The documentation says I can check the error stack in order to get the cause for this.
So I have the function "int SSL_get_error(SSL *s,int ret_code)" which (as I understand) I have to use in order to get the error message. the documentation of the method says nothing about the first parameter of the function. It only says that the second ("ret") parameter should be equal to the return code from the failed operation which can be any of the following :
SSL_connect(), SSL_accept(), SSL_do_handshake(), SSL_read(), SSL_peek(), or SSL_write()
So now I am having two problems. The first is that I didn't use any of those functions but rather use SSL_CTX_new that doesn't return any kind of return code (it returns a pointer to SSX_CTX object) So i don't know what to put as the "ret" parameter. The second problem is that I don't know what does the first parameter mean and what should I put there , because the doc says nothing about it.

You need a valid context to create the SSL object.
Since you can't create a context you can't use SSL_get_error.
Try using ERR_print_errors to see what's gone wrong
#include "openssl/err.h"
...
SSL_CTX * ctx = SSL_CTX_new(....);
if(!ctx) {
ERR_print_errors_fp(stderr);
//throw or return an error
}
I just had a read of the SSL docs. If you need to programatically get the error code / error string you should use the ERR_get_error and ERR_error_string functions.
Have a look here and here

As per http://www.mail-archive.com/openssl-users#openssl.org/msg51543.html, you may be missing a call to SSL_library_init(). Adding this before the SSL_CTX_NEW(..) call fixed the NULL value problem for me.

Related

Cryptic HRESULT errors

The following EndDraw() function returns an HRESULT error code:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371924%28v=vs.85%29.aspx
The documentation specifies:
If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code and sets tag1 and tag2 to the tags that were active when the error occurred.
...and then returns an HRESULT indicating the success of the operations...
I am getting a return value of -2003238911 (0x88990001) which doesn't appear on Microsoft's "Common HRESULT values" page:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa378137%28v=vs.85%29.aspx
I have also searched for the error code in WinError.h but can't find it there either. If it returns this code, there must be a way to find out what it means.
How do I interpret this error code to find out what went wrong?
You use the Google, on which the top result for that hex code has this:
D2DERR_WRONG_STATE
0x88990001
The object was not in the correct state to process the method.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd370979(v=vs.85).aspx
I don't know the first thing about graphics programming or Windows programming, but I think this answers your question, combined with the docs stating that the tag values will be given back to you referring to the point where the error occurred.
Last but not least..
I got the same error, till i realized that i wasn't calling ID2D1HwndRenderTarget::BeginDraw() first in order to prepare the render target for draw calls.
(I just created an account to vote up the answer by Loul G. but I don't have permission to vote yet...)
I have had this same issue...
When BeginDraw() and EndDraw() are called out of order you can get HRESULT: 0X88990001
Trace back to see the order in which they are called.
Also, to help protect against this you can surround BeginDraw(), EndDraw() calls like:
bool beginCalled;
int beginCount;//for debugging
int endCount;//for debugging
//initialize variables somewhere...
void begin(){
rendTarget>BeginDraw();
beginCalled = true;
beginCount++;
}
void end(){
if(beginCalled){
rendTarget->EndDraw();
beginCalled = false;
}
endCount++;
}
//print counts as necessary for debugging

Getting the error message from v8::Script::Compile()

I'm calling Script::Compile() and it returns me an empty handle as result. I've traced into this method and finally found that
i::Handle<i::SharedFunctionInfo> result = i::Compiler::Compile(str, ....
is returning the empty handle. That means compilation error.
But does anyone know is there a way to get error message from compuler in this case to get know where error has occured?
Take a look at the ReportException function in the Shell example. You need to use a v8::TryCatch to capture the exception and report on the error.

Error with addstoredproc method in cfscript

I am calling a stored procedure with cfscript, but when I add the addProcResult method to the call, ColdFusion returns the error The specified key, result, does not exist in the structure. Removing the method fixes the error and doesn't effect the results, but I still would like to know why the error appeared. Using <cfstoredproc> and <cfprocparam> doesn't generate the error. I am running CF9. My code is below.
spService = new storedProc();
spService.setDatasource("mydb");
spService.setProcedure("someSP");
spService.setUsername("TaskRunner");
spService.setPassword("password");
spService.addProcResult(name="result",resultset=1);
spService.execute();
You'll get this error if your stored procedure actually doesn't return a resultset (perhaps it returns an output parameter--or nothing at all).
Simply remove the call to .addProcResult(), and you'll be fine.

Error while calling member function

Hi I have just started using C++ today, and I am working on checkboxes. I have tried using CheckBox1->Checked in an if statement or whatever, but it isn't working.
The error is:
Error 2 error C2227: left of '->Checked' must point to class/struct/union/generic type
EDIT: The Code is:
void function ()
{
if (1001->Checked)
{
Sleep(2000);
}
}
Without seeing some of your code, it's very difficult to offer targeted assistance.
However, that error message usually comes about because the item you're de-referencing is not a pointer.
Check to ensure it's of the correct type. It should be something along the lines of:
tCheckBox *CheckBox1;
One possibility is that you've declared it not as a pointer to the checkbox but as a checkbox itself:
tCheckBox CheckBox1;
Note the lack of the asterisk there that would otherwise mark it as a pointer. In that case, you would use CheckBox1.Checked rather than CheckBox1->Checked, if it's allowed by the framework (this isn't standard C++ since that beast has no concept of GUI libraries).
If that doesn't help, please post the code so we can offer better suggestions.
Update:
if (1001->Checked) ?????
1001 is not a pointer - it's not a variable of any description, it's an integer constant.
You need to declare and use a variable of some description. First step is, I think, to read up on the documentation for your framework and/or get some sample code that does compile and work, basing your initial work of that.
Use CButton::GetCheck() to determine the state of the checkbox - like so...
CButton* pButton = (CButton*) GetDlgItem(IDC_CHECKBOX_RESOURCE_ID);
if ( BST_CHECKED == pButton->GetCheck() )
{
// button is checked
}

If CHttpConnection::OpenRequest returns NULL how do I find out why

c++
mfc
if CHttpConnection::OpenRequest returns a null what can I use to get the internet error.
The mfc artical doesn't say what a bad responce looks like. I just said it returns a handle to a CHttpFile.
Did you see what is the error code returned by GetLastError() ? Get the error code and perform a error lookup (Tools->Error Lookup) to get the description about the code. Normally you will get the exact reason for the failure using this.