Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using PKCS11Interop on docker #212

Closed
misaqsaadat opened this issue Aug 29, 2022 · 8 comments
Closed

using PKCS11Interop on docker #212

misaqsaadat opened this issue Aug 29, 2022 · 8 comments

Comments

@misaqsaadat
Copy link

Hi. I can't use PKCS11Interop on docker. I use it in windows and Ubuntu 20.02. but when I try to use it on docker, I got this error message. (when loading library)
I think my broblem is discussed at #208, but couldn't find solution.

System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory
at Net.Pkcs11Interop.Common.NativeMethods.dlopen(String filename, Int32 flag)
at Net.Pkcs11Interop.Common.UnmanagedLibrary.Load(String fileName) in /src/Pkcs11Interop/Common/UnmanagedLibrary.cs
at Net.Pkcs11Interop.LowLevelAPI80.Pkcs11Library..ctor(String libraryPath) in /src/Pkcs11Interop/LowLevelAPI80/Pkcs11Library.cs
at Net.Pkcs11Interop.HighLevelAPI80.Pkcs11Library..ctor(Pkcs11InteropFactories factories, String libraryPath, AppType appType) in /src/Pkcs11Interop/HighLevelAPI80/Pkcs11Library.cs
at Net.Pkcs11Interop.HighLevelAPI80.Factories.Pkcs11LibraryFactory.LoadPkcs11Library(Pkcs11InteropFactories factories, String libraryPath, AppType appType) in /src/Pkcs11Interop/HighLevelAPI80/Factories/Pkcs11LibraryFactory.cs

@jariq
Copy link
Member

jariq commented Aug 29, 2022

What operating system do you use in your docker image?

@misaqsaadat
Copy link
Author

I use mcr.microsoft.com/dotnet/aspnet:6.0 as base
I think it is based on ubuntu 20.04.
from this:
https://hub.docker.com/_/microsoft-dotnet-aspnet

@jariq
Copy link
Member

jariq commented Aug 30, 2022

I'm no docker expert but as I understand it microsoft-dotnet-aspnet image is available in multiple versions with multiple operating systems. If you want to use version based on Ubuntu 20.04 then you will need to use it wit 6.0-focal tag.

So instead of e.g.

docker pull mcr.microsoft.com/dotnet/aspnet:6.0

you'll need to use

docker pull mcr.microsoft.com/dotnet/aspnet:6.0-focal

@misaqsaadat
Copy link
Author

I'm not docker expert either. dockerizing is for creating apps independent from OS. I use default Dockerfile which is create when creating new project. docker images have a OS with minimal requirements. so we should install extra packages if needed. I don't know what package I should install to use PKCS11Interop. with normal publish, it runs on windows and WSL. but when I create docker image, i get error.
PS: i use mcr.microsoft.com/dotnet/aspnet:6.0-focal. It won't help

@jariq
Copy link
Member

jariq commented Aug 30, 2022

In your first post you wrote that Pkcs11Interop works for you on "Ubuntu 20.02". I don't think that version is correct. Could you please provide correct version of Ubuntu where your app is working fine outside the docker?

@misaqsaadat
Copy link
Author

I'm sorry.I mean 20.04

@jariq
Copy link
Member

jariq commented Sep 4, 2022

Quick update: I was able to reproduce the issue. I've created .NET 6 console app that works fine on Ubuntu 20.04 but does not work on mcr.microsoft.com/dotnet/aspnet:6.0-focal. I'm investigating the issue and will post update here once I have more details to share.

@jariq
Copy link
Member

jariq commented Sep 4, 2022

As it turns out mcr.microsoft.com/dotnet/aspnet:6.0-focal does not contain libdl.so but contains libdl.so.2.

You need to map libdl to libdl.so.2 in your application by using DllImportResolver delegate with NativeLibrary.SetDllImportResolver method. Sample can be seen in #168 (comment) or in Pkcs11LoggerTests project. More detailed explanation can be seen in #208 (comment).

@jariq jariq closed this as completed Sep 4, 2022
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

No branches or pull requests

2 participants