Welcome! Log In Create A New Profile

Advanced

How to send unescaped certificate to backend?

Posted by jairo.fernandez 
How to send unescaped certificate to backend?
December 03, 2021 04:44PM
Hi folks,

I'm using Nginx as my Ingress Controller in a Kubernetes deployment where WSO2 Identity Server is at the backend.
I have a requirement of authenticating clients against the backend using a X509 certificate.
Also, I have to TLS terminate at Nginx.
I managed to put the corresponding certificate from the handshaking to a header in order to pass the request to the backend, like WSO2 Identity Server is expecting.
The issue I'm facing is WSO2 Identity server requires the content of the header to be a standard PEM format, which means not escaped/encoded, just standard Base64 and Nginx send the header escaped (see below for a sample).
I tried using a lua block which effectively unescape the original value to the format I would like to send to the backend, but when the header is received at the backend it's always escaped.

Is there any way to send the content of a header un escaped?

Please help, any comments will be greatly appreciated.


Sample of the escaped certificate:
-----BEGIN CERTIFICATE-----%0AMIIEDjCCAvagAwIBAgIUCG/WzR4Z p1qGX9 lNVU f0K8P4wDQYJKoZIhvcNAQEL%0ABQAwgZYxCzAJBgNVBAYTAkNBMQ8wDQYDVQQIDAZRdWViZWMxETAPBgNVBAcMCE1v%0AbnRyZWFsMRAwDgYDVQQKDAdDaGFrcmF5MQswCQYDVQQLDAJJVDEYMBYGA1UEAwwP%0ASmFpcm8gRmVybmFuZGV6MSowKAYJKoZIhvcNAQkBFhtqYWlyby5mZXJuYW5kZXpA%0AY2hha3JheS5jb20wHhcNMjExMTMwMjEzNTIyWhcNMjIxMTMwMjEzNTIyWjCBmjEL%0AMAkGA1UEBhMCQ0ExDzANBgNVBAgMBlF1ZWJlYzERMA8GA1UEBwwITW9udHJlYWwx%0AEDAOBgNVBAoMB0NoYWtyYXkxCzAJBgNVBAsMAklUMRwwGgYDVQQDDBNjbGllbnRz%0ALmNoYWtyYXkuY29tMSowKAYJKoZIhvcNAQkBFhtqYWlyby5mZXJuYW5kZXpAY2hh%0Aa3JheS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC nYoRD/83%0AW9OYGMyp2wGhoMPcra2rPgHZf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OK7zKuLM6jaCgO
3FGQ1gh9FF2ooDN8GH9tqo5lzxfKtqd2z4HZ1yQ5QGWTDkHFeOJu6iSzLnO3Nayx
6a2 ud8QeN1nZKoMWDy4/BsRilE6Ap/ijQF82g BI/FyUw==
-----END CERTIFICATE-----



Edited 1 time(s). Last edit at 12/03/2021 04:45PM by jairo.fernandez.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 82
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready