Skip to content

sm2加密报错 #229

@Taoja

Description

@Taoja

使用type = "EC" 生成的公钥,在加密时报错,报错信息如下:
pkey:asymmetric_routine EVP_PKEY_encrypt_init: code: -2 evp/pmeth_fn.c:141:error:0608B096:digital envelope routines: EVP_PKEY_encrypt_init: operation not supported for this keytype

代码如下:

local pkey = require "resty.openssl.pkey"
local priv_key, err = pkey.new({
   type = "EC"
})
local pub_pem = priv_key:to_PEM("public")
local pub_key, err = pkey.new(pub_pem)

local plaintext = "测试消息"
local ciphertext, err = pub_key:encrypt(plaintext)
if not ciphertext then
   ngx.say(err)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions