我在使用sha256时遇到了pki库的问题。以下是我遇到问题的以下代码行:
package require pki
set $signature "whatever"
set $keydata "some real 256 RSA key"
set key [::pki::pkcs::parse_key $keydata]
set sig [some_class::base64_url_encode -input [::pki::sign $signature $key sha256]]
以下是我收到的以下错误消息:
can't rename to "::sha2::SHA256Init": command already exists
while executing
"rename ::sha2::${c}-${key} ::sha2::$c"
(procedure "SwitchTo" line 38)
invoked from within
"SwitchTo $e"
("foreach" body line 3)
invoked from within
"foreach e [KnownImplementations] {
if {[LoadAccelerator $e]} {
SwitchTo $e
break
}
}"
(in namespace eval "::sha2" script line 3)
invoked from within
"namespace eval ::sha2 {
variable e {}
foreach e [KnownImplementations] {
if {[LoadAccelerator $e]} {
SwitchTo $e
break
}
}
..."
(file "/usr/local/naviserverXXXX/lib/tcllib1.15/sha1/sha256.tcl" line 820)
invoked from within
"source /usr/local/naviserverXXXX/lib/tcllib1.15/sha1/sha256.tcl"
("package ifneeded sha256 1.0.3" script)
invoked from within
"package require sha256"
(procedure "::pki::sign" line 16)
invoked from within
"::pki::sign $signature $key sha256"
然后我尝试这样做:
catch {namespace delete ::sha256}
package require pki
set $signature "whatever"
set $keydata "some real 256 RSA key"
set key [::pki::pkcs::parse_key $keydata]
set sig [some_class::base64_url_encode -input [::pki::sign $signature $key sha256]]
现在我得到一个不同的错误,说sha256是从不同的库加载的:
can't rename to "::sha2::SHA256Init": command already exists
while executing
"rename ::sha2::${c}-${key} ::sha2::$c"
(procedure "SwitchTo" line 38)
invoked from within
"SwitchTo $e"
("foreach" body line 3)
invoked from within
"foreach e [KnownImplementations] {
if {[LoadAccelerator $e]} {
SwitchTo $e
break
}
}"
(in namespace eval "::sha2" script line 3)
invoked from within
"namespace eval ::sha2 {
variable e {}
foreach e [KnownImplementations] {
if {[LoadAccelerator $e]} {
SwitchTo $e
break
}
}
..."
(file "/web/dev/project-directory/httpd/lib/tcllib1.15/sha1/sha256.tcl" line 820)
invoked from within
"source /web/dev/project-directory/httpd/lib/tcllib1.15/sha1/sha256.tcl"
("package ifneeded sha256 1.0.3" script)
invoked from within
"package require sha256"
(procedure "::pki::sign" line 16)
invoked from within
"::pki::sign $signature $key sha256"
我尝试重新启动服务器,同样的错误一直弹出。是否存在服务器加载问题并且没有使用正确的库依赖项启动?