In openssl, I can get the errorno for the certificate from using the code :
if(SSL_get_peer_certificate(ssl) != NULL){
if((error = SSL_get_verify_result(ssl)) != X509_V_OK){
std::cout << "error no = " << error << std::endl;
}
}
But if I try to get the error string from this error like this:
std::string temp = ERR_error_string(SSL_get_verify_result(ssl), NULL) ;
all i get is:
error:00000013:lib(0):func(0):reason(19)
Is there any way to get the exact reason here?
I have loaded the error strings using this code:
SSL_load_error_strings();
But still i dont get the exact reason. And if i try to use
std::string a = ERR_reason_error_string(19);, The program crashes. What am I doing wrong?
Please use the function X509_verify_cert_error_string to get errors related to Verification of Certificates in OpenSSL. ERR_error_string gives error strings for other SSL lib related errors not for the certificate verification failure specific errors.
As for the crash, there is no reason code mapping to the value 19. All SSL error reason codes start from 100. So, ERR_reason_error_string must be returning NULL which is causing your code to crash.
Related
I am Using this Library For AndroidPdfViewer
https://github.com/barteksc/AndroidPdfViewer
E/PDFView: load pdf error
java.lang.NullPointerException
at com.github.barteksc.pdfviewer.util.Util.toByteArray(Util.java:36)
at com.github.barteksc.pdfviewer.source.InputStreamSource.createDocument(InputStreamSource.java:37)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Here I am Getting nullPointer Exception on This Line.
inputStream=new BufferedInputStream(urlConnection.getInputStream());
It seems that this is not a library error, because it's a NullPointer raising due to the null parameter. your PDFViwer is unable to open the file hence it's throwing null pointer exception. you can check you code for the cause. you should follow the best practices to prevent such situations.
Check the connection first, it should not be null. you can check with ? ternary operator as given below.
// InputStream in = conn.getInputStream();
// check for the null connection first, it's possible that connection could not be made before opening the InputStream.
InputStream in = (conn != null) ? conn.getInputStream() : null;
I am trying to use pocketsphinx as part of a c++ program and have a problem when running my code. I had two issues: The first being that my microphone wasn't being recognized by pocketsphinx and the second being a seg fault when ps_start_utt was called. I'm running this on ubuntu 14.04. Here is the original code:
ps_decoder_t *ps;
cmd_ln_t *config;
ad_rec_t *ad;
config = cmd_ln_init(NULL, ps_args(), TRUE,
"-hmm", "/usr/local/share/pocketsphinx/model/en-us/en-us",
"-lm", "../audio/1638.lm",
"-dict", "../audio/1638.dic",
"-logfn", "/dev/null",
NULL);
ps = ps_init(config);
ad = ad_open_dev("sysdefault", (int) cmd_ln_float32_r(config, "-samprate"));
// below is the other thing I tried to use to open the audio device.
// ad = ad_open();
cout << "AAAA" << endl;
ad_start_rec(ad);
cout << "BBBB" << endl;
ps_start_utt(ps);
cout << "CCCC" << endl;
utt_started = FALSE;
When executed, this produced two errors at the command line. The first was an error about being unable to find the sysdefault audio device and the second was a seg fault that occurred after AAAA and BBBB were outputted (CCCC was never printed).
This means that something in ps_start_utt is causing a seg fault but I have no idea what. I originally thought the two errors were related so I tried to fix the first one. By replacing the string sysdefault with NULL in ad_open_dev the first error no longer appears but the seg fault still happens.
Using ad_open() instead of ad_open_dev is the same as substituting NULL; the first error is no longer present but the seg fault still occurs in the same place. However, the strangest thing to me about this issues is that the pocketsphinx_continuous -inmic yes command works perfectly on the same machine with the same mic. I have looked at the continuous.c code on the cmusphinx repository but haven't been able to figure out what the difference is or how I might correct it. I can post more of the code if necessary. Any help would be greatly appreciated!
UPDATE: After doing some checks I found that the error that causes the seg fault is that ps == NULL. I'm still not sure why this would be happening however.
I am using following simple code to connect to database and I am getting error as ORA-24399 which says invalid number of connections specified. I have googled enough but not clue. This is a CPP program.
Following is code Snippet:
try
{
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *con= env->createConnection("test","test","testdb");
}
catch(SQLException ex)
{
cout<<ex.getMessage().c_str();
}
P.S Using SQL Plus I am able to connect to the database where this code is being run. There are no issues there. Only through program there is a failure seen.
P.P.S Tried using connectionpool as well but still no luck...
Looking at your error, it seems that the problem is somewhere else in your code: you should fix the parameters (related to connection numbers) in the call to OCIConnectionPoolCreate.
#include<iostream>
#include<iomanip>
#include<occi.h>
#include<string>
using namespace std;
using namespace oracle::occi;
int main (void){
string utilizador ="B3_1";
string password ="B3_1";
string bd ="gandalf.dei.isep.ipp.pt:1521/pdborcl";
try{
Environment *env;
Connection *ligacao;
Statement *instrucao;
env = Environment::createEnvironment (Environment::DEFAULT);
ligacao = env->createConnection (utilizador, password, bd);
cout <<"BDdad: a ligar ..."<< endl;
}catch(SQLException erro){
cerr <<"Erro: "<< erro.getMessage () << endl;}
cin.get();
return 0;
}
For this college project I need to connect Visual Studio 2012 to Oracle in order to interact with the database through VS. The problem is, all my workgroup can connect without any errors but in my case it's slightly different. I get a SQL Exeception in the line "env = Environment::createEnvironment (Environment::DEFAULT);". The error code is 1804, and the message it displays is "error while trying to retrieve text for error ORA-01804". I thought it could be the paths but I have the same as my friends and they can connect and I don't. Have this ever happened or is it normal ?
EDIT:
My teacher advised me to change the version of the Visual Studio 2012. I had the Ultimate version and he told to use the Express to see if works. Already did that and the result is the same. I looked all over the internet and couldn't find a straight answer to my problem.
Error code #32104 indicates that an error occurred in the call but the actual error message could not be retrieved. Essentially this means that Environment::createEnvironment failed then tried to acquire message associated with the error. When it couldn't find it the 32104 error was returned instead.
Because of this the exact cause of the error may be difficult to determine. I do suggest that you ensure both ORACLE_HOME and ORACLE_SID are defined in your shell environment.
Please tell me why iam always getting "Server Upload Failed!" in the code
given below.
int rval = 28;
char *return_str=NULL;
return_str = strdup((rval!=28) ? ("Server Upload Failed!") : ("Server TimeOut Reached!"));
printf(" return_str : %s\n", return_str);
Output that iam getting is ====> Server Upload Failed! . I want to know why it is not giving
"Server TimeOut Reached!" as output .
Platform : Linux , gcc-compiler
It looks correct to me, once I read it a couple of extra times. It should generate the latter string ("Server TimeOut Reached").
Not sure why you would ever need to call strdup() on a static string, instead of just using the literal directly. One case would be if there sometimes a need for a more dynamic string I guess, so whoever receives the value assumes it's dynamic and takes ownership.