Is there a file (place) to get all those error strings that openssl ERR_error_string_n api return?

0 投票
最新提问 用户: (280 分)

So the ERR_error_string_n api gives me the output in the following format.

error:[error code]:[library name]:[function name]:[reason string]

I'm developing a product application and my requirement is that i need to give my own string as output to the log file, which is more readable and abstract for anyone facing that error, rather than the one that SSL dumps.

So instead of:

error:14082174:SSL routines:ssl3_check_cert_and_algorithm:dh key too small

I can dump just:

error: Handshake failure. dh key too small.

If i get all the possible error strings that SSL dumps, i can have a map that matches this string to a custom string of mine.

Did a bit of googling and openssl code browsing, but failed in getting the location storing the error strings.

Is there is a way i can achieve this ?

2 个回答

0 投票
最新回答 用户: (140 分)

The function ERR_reason_error_string() gives you just the last bit of the error message rather than all the rest of it. The other components if you want those are just the raw error code, the library (use ERR_lib_error_string()) and the function (use ERR_func_error_string()).

By using those functions you can create your custom error message by just using the component parts that you want.

0 投票
最新回答 用户: (980 分)

You can use

unsigned long ERR_get_error(void);

to obtain the error and then decided how to present it to the user.

You can obtain details from the error code returned from that function using these functions:

欢迎来到 Security Q&A ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。