<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Ok,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
so from what you are saying, my order like this:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<pre><i></i>dynamic --> set SO_PATH --> LOAD and then set all parameters of<br>the engine that SO_PATH implements. i.e MODULE_PATH<i></i></pre>
is correct?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
BR</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Piotr</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Od:</b> Selva Nair <selva.nair@gmail.com><br>
<b>Wysłane:</b> czwartek, 27 maja 2021 00:44<br>
<b>Do:</b> Piotr Lobacz <piotr.lobacz@softgent.com><br>
<b>DW:</b> openssl-users@openssl.org <openssl-users@openssl.org><br>
<b>Temat:</b> Re: dynamic engine load</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">Hi,</div>
<br>
<div class="x_gmail_quote"></div>
<div dir="ltr" class="x_gmail_attr">On Wed, May 26, 2021 at 4:45 PM Piotr Lobacz <<a href="mailto:piotr.lobacz@softgent.com" target="_blank">piotr.lobacz@softgent.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Btw i have verified that in openssl command line tool if i switch order from the one that worked for me:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
OpenSSL> engine dynamic -pre SO_PATH:/usr/lib/engines-1.1/libpkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:/usr/lib/libckteec.so<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
to the one that was in the code:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
OpenSSL> engine dynamic -pre SO_PATH:/usr/lib/engines-1.1/libpkcs11.so -pre MODULE_PATH:/usr/lib/libckteec.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
the error is the same as for me in the C# code. So the question is if you are telling me that the proper order is like that:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
dynamic --> set SO_PATH --> LOAD and then set all parameters of
<div>the engine that SO_PATH implements.</div>
<div><br>
</div>
does the order which i used is also correct one?</div>
</div>
</blockquote>
<div><br>
</div>
<div>The main error in your original code was setting MODULE_PATH on the dynamic engine instead of on pkcs11.  And, I mistyped saying set ID after LOAD. As for LIST_ADD, if required, should be specified before LOAD as it's a directive to the dynamic engine,
 not pkcs11.</div>
<div><br>
</div>
<div>It has been a while since I have looked into dynamic loading in detail, but here is my understanding. </div>
<div><br>
</div>
<div>The dynamic engine supports only a few controls out of which the most useful ones are SO_PATH, ID and LIST_ADD. It won't understand MODULE_PATH. And, if  SO_PATH is not given, I think ID could be used to locate the so-path of the engine but I have never
 got it to work. In any case, as you are giving the full SO_PATH, you don't need to set the ID. A "wrong" ID may lead to load failure but no ID will succeed. There may be some use of ID if the same shared lib implements multiple engines with different IDs.
 I don't know.</div>
<div><br>
</div>
<div>The LOAD control causes the dynamic engine to convert itself to a new engine. Almost all engine parameters are wiped clean (including id and name) and the shared library pointed to by SO_PATH is loaded. The bind function defined in the shared lib gets
 executed which will fill-in the new engine parameters and set up the methods it supports. In the case of pkcs11, It sets the id to "pkcs11" on loading. So, after loading, querying the ID using Engine_get_id() will return "pkcs11".</div>
<div><br>
</div>
<div>LOAD also causes the engine to be added to the internal list if LIST_ADD was specified before LOAD, not otherwise.</div>
<div><br>
</div>
<div>Once loaded, the pkcs11 engine can handle controls like MODULE_PATH. It will use it to locate the module and load it when required -- usually after Engine_init() is called.</div>
<div><br>
</div>
<div>Selva</div>
</div>
</div>
<a href="https://www.softgent.com" target="_blank"><img width="150" height="50" src="https://softgent.com/wp-content/uploads/2020/01/Zasob-14.png"></a>
<p style="color: gray; display: block; font-size: 9px; text-transform: uppercase; margin: 0; margin-top: 10px;">
<b>Softgent Sp. z o.o.</b>, Budowlanych 31d, 80-298 Gdansk, POLAND</p>
<p style="color: gray; display: block; font-size: 9px; text-transform: uppercase; margin: 0;">
KRS: 0000674406, NIP: 9581679801, REGON: 367090912</p>
<p style="color: gray; display: block; font-size: 9px; text-transform: uppercase; margin: 0;">
www.softgent.com</p>
<p style="color: gray; display: block; font-size: 9px; text-transform: uppercase; margin: 0; margin-top: 10px;">
Sąd Rejonowy Gdańsk-Północ w Gdańsku, VII Wydział Gospodarczy Krajowego Rejestru Sądowego</p>
<p style="color: gray; display: block; font-size: 9px; text-transform: uppercase; margin: 0;">
KRS 0000674406, Kapitał zakładowy: 25 000,00 zł wpłacony w całości.</p>
</body>
</html>