Skip to content

Fixed compile error for OpenSSL 1.0 systems (#3739)#3912

Merged
aleks-f merged 1 commit intopocoproject:develfrom
gyee-penguin:issue-3739
Mar 17, 2023
Merged

Fixed compile error for OpenSSL 1.0 systems (#3739)#3912
aleks-f merged 1 commit intopocoproject:develfrom
gyee-penguin:issue-3739

Conversation

@gyee-penguin
Copy link
Copy Markdown
Contributor

@gyee-penguin gyee-penguin commented Jan 4, 2023

Trying again -- not sure why it failed checks last time.

@gyee-penguin gyee-penguin force-pushed the issue-3739 branch 2 times, most recently from 69d15c5 to 570ec33 Compare January 5, 2023 17:15
@aleks-f aleks-f added this to the Release 1.12.5 milestone Jan 11, 2023
@aleks-f
Copy link
Copy Markdown
Member

aleks-f commented Jan 11, 2023

Pull requests should go to develop branch

@gyee-penguin gyee-penguin changed the base branch from poco-1.12.5 to devel January 11, 2023 19:23
@gyee-penguin
Copy link
Copy Markdown
Contributor Author

Oops, my apologies. I've changed the Pull Request to base off of devel.

@gyee-penguin
Copy link
Copy Markdown
Contributor Author

Hello @aleks-f I don't think our patch is the reason for the checks failing. I think the checks in the devel branch were failing before we committed.

@gyee-penguin
Copy link
Copy Markdown
Contributor Author

Rebased with latest devel to see if that helps it pass checks

@gyee-penguin
Copy link
Copy Markdown
Contributor Author

There seems to be a bug with the github checks.

@bas524
Copy link
Copy Markdown
Contributor

bas524 commented Feb 5, 2023

Hi! I think, that problem a little bit more complicated than this PR. Please look at #3939
It's illegal to comare 1 with result of function which has void as a return param. My topic correct for openssl 1.0.2.
And this PR correct only for opennsl version where EVP_CIPHER_CTX_init has int as return param

@gyee-penguin
Copy link
Copy Markdown
Contributor Author

Hello! Our patch does address the problem you mention. We use a C macro to test the OpenSSL version and handle both cases (one where the function returns void and one that returns an int).

@gyee-penguin
Copy link
Copy Markdown
Contributor Author

Hello @aleks-f Do you know if our patch is acceptable for the 1.12.5 release?

@bas524
Copy link
Copy Markdown
Contributor

bas524 commented Feb 6, 2023

Hello! Our patch does address the problem you mention. We use a C macro to test the OpenSSL version and handle both cases (one where the function returns void and one that returns an int).

Please, try build with openssl version 1.0.2. And you will see that in this version EVP_CIPHER_CTX returns void, and it will be a compile time error.
I have gotten it on solaris with openssl 1.0.2f

@gyee-penguin
Copy link
Copy Markdown
Contributor Author

Hello @bas524,

We successfully compiled against OpenSSL 1.0.2k on CentOS 7. I agree that EVP_CIPHER_CTX_init returns void. I can't explain why you are getting compile errors on your Solaris system, but below I explain why our patch works:

#if OPENSSL_VERSION_NUMBER >= 0x10100000L
	if (1 != EVP_CIPHER_CTX_init(_pCtx))
		handleErrors(std::string("Envelope():EVP_CIPHER_CTX_init()"));
#else
	EVP_CIPHER_CTX_init(_pCtx);
#endif

The first line #if OPENSSL_VERSION_NUMBER >= 0x10100000L tests if the OpenSSL version is >= 1.1.0. If this is true, then we compile the version of EVP_CIPHER_CTX_init that returns an int.

Otherwise, we compile the version that returns void. This is true if OpenSSL version is 1.0.2, for example.

@bas524
Copy link
Copy Markdown
Contributor

bas524 commented Feb 10, 2023

Hello @bas524,

We successfully compiled against OpenSSL 1.0.2k on CentOS 7. I agree that EVP_CIPHER_CTX_init returns void. I can't explain why you are getting compile errors on your Solaris system, but below I explain why our patch works:

#if OPENSSL_VERSION_NUMBER >= 0x10100000L
	if (1 != EVP_CIPHER_CTX_init(_pCtx))
		handleErrors(std::string("Envelope():EVP_CIPHER_CTX_init()"));
#else
	EVP_CIPHER_CTX_init(_pCtx);
#endif

The first line #if OPENSSL_VERSION_NUMBER >= 0x10100000L tests if the OpenSSL version is >= 1.1.0. If this is true, then we compile the version of EVP_CIPHER_CTX_init that returns an int.

Otherwise, we compile the version that returns void. This is true if OpenSSL version is 1.0.2, for example.

I'm sorry. I was wrong. It was my inattention.
Your fix is correct. I have reused it for PR with fixes for solaris

@aleks-f aleks-f merged commit 85f7486 into pocoproject:devel Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants