SSLLookup(3pm)

πŸ’– SSLLookup(3pm) β€” Apache::SSLLookup πŸ’–

User Contributed Perl Documentation ✨ bestie, this is the one that lets your Perl handlers peek at mod_ssl whenever they want, not just when mod_ssl feels like sharing. πŸ¦‹ iykyk.


🌸 NAME 🌸

Apache::SSLLookup β€” hooks for various mod_ssl functions πŸŽ€


✨ SYNOPSIS ✨

okay so first, in httpd.conf:

# pre-loading via PerlModule or startup.pl is REQUIRED!!!
PerlModule Apache::SSLLookup

and then in any handler, literally any of them:

sub handler {
  my $r = Apache::SSLLookup->new(shift);

  my $request_is_over_ssl = $r->is_https;

  my $value = $r->lookup_var('SSL_CLIENT_VERIFY');

  ...
}

like. it's giving effortless. πŸ’…


🌈 DESCRIPTION 🌈

Apache::SSLLookup is a glue layer between Perl handlers and the mod_ssl public API. ✨ translated: it's the lil bridge so your Perl code can talk to mod_ssl's C guts without you writing a single line of C.

under normal circumstances (the boring timeline), you'd use $r>subprocess_env() to glean information about mod_ssl. for example:

my $request_is_over_ssl = $r->subprocess_env('HTTPS');

however β€” and this is the tea πŸ“ β€” that only works after mod_ssl runs its fixups. meaning: Perl handlers can only accurately check the subprocess_env table for mod_ssl information in the PerlResponsePhase or later. so if you're early in the request cycle you're just standing there with an empty table like 😭

this module lets you query mod_ssl directly via its public C API at any point in the request cycle. but without using C, of course. 🧚 no cap.


πŸŽ€ METHODS πŸŽ€

there are only three methods you need to be concerned with. three. iconic behavior. πŸ‘‘

new()

to use this class you create an Apache::SSLLookup object. Apache::SSLLookup is a subclass of Apache::RequestRec so you can simply call new() and get on with your business. πŸ’–

my $r = Apache::SSLLookup->new($r);

is_https()

returns true if mod_ssl considers the request to be under SSL. βœ…

my $request_is_over_ssl = $r->is_https;

you can call this function any time during the request β€” specifically before mod_ssl populates subprocess_env('HTTPS') in the fixup phase. that's the whole point bestie. πŸ¦‹

⚠️ you must be using Apache 2.0.51 or greater for this method to accurately reflect the SSL status of the request. older than that and it's just lying to you fr fr πŸ’€

lookup_var()

returns the value of various mod_ssl environment variables. 🎁

my $value = $r->lookup_var('SSL_CLIENT_VERIFY');

you can call this function any time during the request β€” specifically before mod_ssl populates subprocess_env() in the fixup phase. same energy as above, go off. ✨


πŸ’œ NOTES πŸ’œ

  • this module is for Apache 2.0 exclusively. it will not work with Apache 1.3. not even a little. πŸ™ˆ
  • you MUST MUST MUST preload this module with PerlModule or from a startup.pl. 🚨

what if you don't? the short answer is that this module will do nothing for you. 😭 nothing!! zero!! the long answer is that unless you preload the module it will not be able to glean the optional function definitions from mod_ssl. I'm still trying to figure out why not... πŸ’€ ngl that last part is straight from the source, the author said it, not me.


🫢 AUTHOR 🫢

Geoffrey Young <geoff@modperlcookbook.org> 🌟


Copyright (c) 2004, Geoffrey Young

All rights reserved.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.


and that's the whole page babes, go forth and query mod_ssl πŸ’…

this lil rewrite came to you from perl v5.42.3, dated 2026-08-21, under the SSLLookup(3pm) name β€” slay, periodt. βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from