spacewander / lua-resty-rsa

RSA encrypt/decrypt & sign/verify for OpenResty/LuaJIT
MIT License
266 stars 101 forks source link

get a nil from new() #22

Closed FelizQ closed 6 years ago

FelizQ commented 6 years ago

I use a multiline string to init a new pubkey and got 'bad end line ' ERR . example:

pubkey = [[-----BEGIN PUBLIC KEY----- asdfasdfasdfasdfasdfasdfasdfasdfas gafasdfasdfasdfasdfasdfasdf dfasdfasdfasdfas fasdfasdfasdfasdfas -----END PUBLIC KEY-----]]

pub , err = rsa:new({public_key = pubkey})

then pub is nil , err is 'bad end line'

does the opt value require specific format ? thanks a lot

spacewander commented 6 years ago

@FelizQ I think you need to specify the key_type? Like: https://github.com/doujiang24/lua-resty-rsa/blob/master/t/rsa.t#L722

FelizQ commented 6 years ago

I had tried both of the key types and the result is the same

spacewander commented 6 years ago

@FelizQ Interesting. The bad end line error means the ending of the public key input is not correct. Have you verified the public key with OpenSSL commandline tool? Could you provide a reproduce case so that I could test by myself?

FelizQ commented 6 years ago

@spacewander
I had found the cause : the pub key string had been quoted by an interface :( thanks for your help