Hello!
2013/3/24 lisbar:
> 春哥好!
> 最近在使用openresty中,使用resty.des和resty.aes对字符串进行加解密时,遇到了这样的问题.
我维护的 lua-resty-string 项目里并没有提供 resty.des 这个 Lua 模块:
https://github.com/agentzh/lua-resty-string
你使用的是 resty.des 是在哪里?
> 每当我重启nginx后,如果首先使用des解密,des解密正确,这时再使用aes解密,就会报错,像这样
> /usr/local/openresty/lualib/resty/aes.lua:102: attempt to redefine
> 'evp_cipher_ctx_st' at line 5 stack traceback:coroutine 0:[C]: in function
> 'require'
这是因为 evp_cipher_ctx_st 这个结构体在你的 resty.des 和 resty.aes 里面重复定义了,而 LuaJIT
的 FFI 是不允许同名的 C 名字被重复定义(否则就报你看到的这个错误)。为避免重复定义,可以使用 openresty
邮件列表中这个主题讨论中建议的方法(从中国境内访问可能需要翻墙):
https://groups.google.com/group/openresty/browse_thread/thread/56c84e681130c137/a26e53ee8495af45
> 如果这时我再重启nginx,首先使用aes解密,aes解密正确,接着再使用des解密,也会报错:
> /usr/local/openresty/lualib/resty/des.lua:82: attempt to redefine
> 'evp_cipher_ctx_st' at line 5 stack traceback: coroutine 0: [C]: in function
> 'require'
这里的原因也是一样的。
同时抄送给 openresty 中文邮件列表:https://groups.google.com/group/openresty
建议你也加入 openresty 中文邮件列表并总是在那里讨论这样的问题,谢谢合作 :)
Best regards,
-agentzh