Ok i am trying to use this code:
TokenEngine::TokenEngine( const StringList & modulePaths )
{
ENGINE * tok = ENGINE_by_id( "pkcs11" );
if ( ! tok )
throw Exception( "token: unable to get engine" );
m_pEngine = tok;
const string modulePath( findFirstExisting( modulePaths ) );
if ( modulePath.empty() )
throw Exception( "token: unable to find module path" );
DEBUG( "token: ctor: module_path=" << QS( modulePath ) );
if ( 1 != ENGINE_ctrl_cmd_string( tok, "MODULE_PATH", modulePath.c_str(), CMD_MANDATORY ) )
throw Exception( "token: setting module_path <= " + QS( modulePath ) );
DEBUG( "token: ctor: initializing " << m_pEngine );
if ( 1 != ENGINE_init( tok ) )
throw Exception( "token: unable to initialize" );
DEBUG( "token: ctor: done" );
}
which is from this site https://github.com/tkil/openssl-pkcs11-samples/blob/master/OpenSSLWrappers.cpp and the problem is that if i change modulePath value
to a not existing file the method is still returning 1 which i think it should not. Correct me if i'm wrong.
BR
Piotr
Od: Michael McKenney <mike.mckenney@xxxxxxxxxxxxxxxx>
Wysłane: poniedziałek, 24 maja 2021 14:17 Do: Piotr Lobacz <piotr.lobacz@xxxxxxxxxxxx>; openssl-users@xxxxxxxxxxx <openssl-users@xxxxxxxxxxx> Temat: RE: CSR generation using pkcs11 token engine from C# code Usually I reserve C# for Windows servers. I use PHP on Ubuntu other Linux Distros. Most web servers that need OpenSSL are Linux. Glad you got it working.
From: Piotr Lobacz <piotr.lobacz@xxxxxxxxxxxx>
Hi Michael, thx for your quick reply. Unfortunately i can't use your script because i need to use native code not bash implementation.
For the first question about loading token module i have found a solution on github https://github.com/tkil/openssl-pkcs11-samples . This code is a C/C++ code but i can fairly port it to C#, and i was right about different load of engine for pkcs11 engine. So this can be closed.
Another thing is to generate CSR with the usage of token and openssl. This will be more complicated and i don't know yet how to do that.
BR Piotr
Od: Michael McKenney <mike.mckenney@xxxxxxxxxxxxxxxx>
I wrote this script years ago when I switched to Godaddy 10 site certificates. I don't use it from C# You could easily put it into C# or PHP. < > would be variables at the top. I have it filled in so I just modify the alt_names.
I just cut and paste the all of it into Ubuntu and run it in the directory /etc/apache2/ssl. If you don't need all 10, you can delete the extra ones in alt_names.
|