0

I need to add our custom self signed certificate in .pem format to .so library. In our company we use c++ library which works as layer between our android/iOS app and our server in internal network. It formats request and send http request over network using poco. Now we need to switch to https for what I have to set up SSLManager of poco. It needs to be configured with our self signed certificate. For that I do something like this.

My problem is that I need to pack certificate in .pem format inside .so lib. And access that certificate from class in that lib. Certificate is addressed by path like this

Poco::Net::Context::Ptr ptrContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "rootcert.pem", Poco::Net::Context::VERIFY_STRICT, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");

Details here

I think that I add certificate to .so correctly in cmake by:

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/rootcert.pem DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

How can I address it then with path? Thanks

data
  • 2,563
  • 1
  • 21
  • 25
Matej Procházka
  • 217
  • 2
  • 14

1 Answers1

0

Compile file which includes .pem file like:

char* pem="-----BEGIN RSA PRIVATE KEY----- .. . . . . . -----END RSA PRIVATE KEY----- "

gcc -c -Wall -Werror -fpic examplePem.c
gcc -shared -o pem.so examplePem.o

You can load the so file, then simple access to pem variable.