Core\Http\TlsInfo::issuer
Returns the name of the certificate authority that signed the certificate of the server a connection went to, as text like CN=Example Root CA, O=Example Trust.
A certificate authority is an organization that signs certificates. Its signature says that the certificate really belongs to the server named in it. issuer() returns the authority's name in the same KEY=value form as subject(). The text is tainted (it came from outside the program), because the other server sent the certificate.
You get a Core\Http\TlsInfo from Core\Http\Response::tls(). That method returns null for a reply that did not come over TLS, so check for null first.
Good to know: the examples build their TLS connections with Core\Test::tlsSession, so they run without a network. They show the issuer, the subject and the issuer side by side, and an audit that finds servers whose certificate a different authority signed.
Return value
Returns tainted string. Who signed the leaf certificate, in the same format as subject. It is tainted, because the server chose this text.
Errors
RuntimeErrorThe server sent no certificate, or its leaf certificate is not X.509 that this method can read.version,cipher,isVerifiedandpeerChainstill work, because they do not read inside a certificate.
Examples
Reading the issuer
<?nvs// Shows how to read who signed the certificate of the server that sent a reply.
// `Core\Test::tlsSession` builds a TLS connection for a test, so the example runs// without a network. `Core\Test::answerHttp` gives a fixed reply that reports it.var $session = Core\Test::tlsSession({ issuer: 'CN=Example Root CA, O=Example Trust' });Core\Test::answerHttp('https://api.example.com/health', 200, { tls: $session });
?Core\Http\TlsInfo $info = Core\Http\Client::get('https://api.example.com/health')->tls();
// `issuer()` returns the name of the certificate authority that signed the// server's certificate. This prints `CN=Example Root CA, O=Example Trust`.if ($info != null) { echo $info->issuer(), "\n";}CN=Example Root CA, O=Example TrustThe subject and the issuer
<?nvs// Shows the difference between the subject and the issuer of one certificate.
// A TLS connection built for a test, so the example runs without a network.var $session = Core\Test::tlsSession({ subject: 'CN=shop.example.com', issuer: 'CN=Example Root CA',});
// `subject()` is the server the certificate is for. `issuer()` is who signed it.// This prints `for: CN=shop.example.com` and `signed by: CN=Example Root CA`.echo 'for: ', $session->subject(), "\n";echo 'signed by: ', $session->issuer(), "\n";for: CN=shop.example.comsigned by: CN=Example Root CAServers outside the company authority
<?nvs// Shows an audit of internal servers. Each one must have a certificate signed// by the company's own certificate authority.
// Fixed replies with TLS connections built for a test, so the example runs// without a network. The `stock` server has a certificate from another authority.Core\Test::answerHttp('https://billing.example.com/health', 200, { tls: Core\Test::tlsSession({ issuer: 'CN=Example Internal CA, O=Example' }),});Core\Test::answerHttp('https://stock.example.com/health', 200, { tls: Core\Test::tlsSession({ issuer: 'CN=Public CA, O=Public Trust' }),});Core\Test::answerHttp('https://users.example.com/health', 200, { tls: Core\Test::tlsSession({ issuer: 'CN=Example Internal CA, O=Example' }),});
string $company = 'CN=Example Internal CA, O=Example';array<string> $hosts = ['billing.example.com', 'stock.example.com', 'users.example.com'];
// The loop compares each issuer with the company's authority.// This prints `stock.example.com: CN=Public CA, O=Public Trust` and then `outside: 1`.uint $outside = 0;foreach ($hosts as string $host) { ?Core\Http\TlsInfo $info = Core\Http\Client::get('https://' . $host . '/health')->tls(); if ($info != null) { if ($info->issuer() != $company) { echo $host, ': ', $info->issuer(), "\n"; $outside = $outside + 1; } }}echo 'outside: ', $outside, "\n";stock.example.com: CN=Public CA, O=Public Trustoutside: 1