简体   繁体   English

以非 root 用户身份通过​​ softhsm2 创建令牌时出错“无法初始化库”

[英]Error creating token via softhsm2 as non-root user "Could not initialize the library"

Whilst initializing a token via softhsm2-util as a non-root user I receive the following error:在以非 root 用户身份通过​​ softhsm2-util 初始化令牌时,我收到以下错误:

$ softhsm2-util --init-token --slot 0  --label "test" --so-pin 5462 --pin 8764329

ERROR: Could not initialize the library.

How can I fix this?我怎样才能解决这个问题?

Whilst initializing token as a non-root user, we invariably try to access the default /etc/softhsm/softhsm2.conf which points tokens to be staged under /var/lib/softhsm/tokens whose ownership/permission is limited to be used by root and its associated groups.在以非 root 用户身份初始化令牌的同时,我们总是尝试访问默认的/etc/softhsm/softhsm2.conf ,它指向将在/var/lib/softhsm/tokens/var/lib/softhsm/tokens其所有权/权限仅限于使用root 及其关联的组。

Changing ownership/permission of /var/lib/softhsm/tokens doesn't solve the problem as we cannot access /etc/softhsm/softhsm2.conf in the first place given the access limitation, so we should be doing this instead:更改/var/lib/softhsm/tokens所有权/权限并不能解决问题,因为考虑到访问限制,我们首先无法访问/etc/softhsm/softhsm2.conf ,所以我们应该这样做:

cd $HOME
mkdir -p $HOME/lib/softhsm/tokens
cd $HOME/lib/softhsm/
echo "directories.tokendir = $PWD/tokens" > softhsm2.conf
export SOFTHSM2_CONF=$HOME/lib/softhsm/softhsm2.conf

$ softhsm2-util --init-token --slot 0 --label "test" --so-pin 5462 --pin 8764329
The token has been initialized.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM