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?

csaar
  • 530
  • 5
  • 22
subrat padhi
  • 151
  • 1
  • 2
  • 11
  • Which module are you using for `openssl_x509.new`? What's the functionality of `getSubject()`? – csaar Apr 29 '19 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" – subrat padhi Apr 29 '19 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=(.*),')`. – csaar Apr 29 '19 at 15:06

0 Answers0