Tcl错误:can';t重命名为";::sha2::SHA256Init“命令已存在
我在使用sha256时遇到pki库问题。以下是我遇到问题的代码行:Tcl错误:can';t重命名为";::sha2::SHA256Init“命令已存在,tcl,Tcl,我在使用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]] 以下是我收
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"
我尝试重新启动服务器,但同样的错误不断出现。使用正确的库依赖项加载和引导服务器是否有问题 如果您尝试完全不使用
包require
,会发生什么情况?看起来符号已经调用它了。不应该引起冲突,但只是好奇。如果没有package require,它会抛出一个错误,说明它需要pki库。。在解决这个问题时,我唯一想到的是通过删除包require pki来启动服务器。等到它出现故障,告诉我它缺少需要pki的包。然后包含需要pki的包。然后它就工作了。如果您尝试完全不使用包require
,会发生什么?看起来符号已经调用它了。不应该引起冲突,但只是好奇。如果没有package require,它会抛出一个错误,说明它需要pki库。。在解决这个问题时,我唯一想到的是通过删除包require pki来启动服务器。等到它出现故障,告诉我它缺少需要pki的包。然后包含需要pki的包。然后它就起作用了。