Skip to content

Instantly share code, notes, and snippets.

@jandd
Created March 21, 2015 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jandd/9c69f602fb534a47c0ee to your computer and use it in GitHub Desktop.
Save jandd/9c69f602fb534a47c0ee to your computer and use it in GitHub Desktop.
Getting the CN from a client certificates SubjectDN and put it into a header with nginx and LUA
set_by_lua $ssl_client_s_dn_subject_cn '
dn = ngx.arg[1];
cnstart = string.sub(dn, string.find(dn, "/CN=") + 4);
return string.sub(cnstart, 0, string.find(cnstart, "/") - 1);
' $ssl_client_s_dn;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment