Added PKI middleware functionality