0

I am reading the ngnix client certificate and storing it in a local variable.

local client_cert = openssl_x509.new(ngx.var.ssl_client_raw_cert)
local subject = client_cert:getSubject()

I need to get the common name from the subject, how can I get it?

3
  • Which module are you using for openssl_x509.new? What's the functionality of getSubject()? Commented Apr 29, 2019 at 13:35
  • I am using local openssl_x509 = require "openssl.x509" and local openssl_store = require "openssl.x509.store". getSubject() is giving some certificate details : CN=blr2preman1, client: 10.120.10.151, server: kong, request: "GET /example HTTP/1.1", host: "10.120.9.149:8443" Commented Apr 29, 2019 at 13:46
  • Which type has subject after client_cert:getSubject()? I can't figure it out, only by reading the doc. If you get a table object, you can simply use subject.CN. In case of string (for instance after subject:text()), following lua pattern should work string.match(urvar, 'CN=(.*),'). Commented Apr 29, 2019 at 15:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.