Developing in Golang
Using the GitHub Library
To use Unbound PKCS#11 Implementation via Golang wrapper provided in GitHub, select the Unbound target-specific PKCSPublic-Key Cryptography Standards - Industry-standard cryptography specifications.#11 library from the Unbound PKCS#11 Library and define/use it in the wrapper.
For example,
p := pkcs11.New("/usr/lib/libekmpkcs11.so")
err := p.Initialize()
if err != nil {
panic(err)
}
Note
For the platform-dependent location of the libekmpkcs11.so, refer to Path to PKCS#11 Library.
Warning
By default, CORE locks the PKCSPublic-Key Cryptography Standards - Industry-standard cryptography specifications.#11 session execution to a single thread, but Golang uses different OS threads by default. To prevent any issues, you must set session-thread=0 in the configuration file.
Testing
To perform tests specified in GitHub PKCS#11 Wrapper for Go, replace the SOFTHSM attributes by the following:
> export SOFTHSM_LIB=/usr/local/lib/libekmpkcs11.so > export SOFTHSM_PIN=<user_password> > export SOFTHSM_TOKENLABEL=<name of the partition>
and run
> go test