SSL(3)

🌸 SSL(3) β€” like, the manual page, but make it cute 🌸

okay bestie, so this is a page from the User Contributed Perl Documentation (yes, that's the manual name, don't @ me) and honestly? it's giving "niche but iconic." it's SSL(3), and it's about a little Perl thing that lets you be an HTTPS server. let's get into it πŸ’…


✨ NAME ✨

HTTP::Daemon::SSL β€” a simple http server class with SSL support. yes, the whole vibe is "http server, but make it encrypted." πŸ”₯


✨ SYNOPSIS ✨

like, here's the whole flex, copy-paste energy:

  use HTTP::Daemon::SSL;
  use HTTP::Status;

  # Make sure you have a certs/ directory with "server-cert.pem"
  # and "server-key.pem" in it before running this!
  my $d = HTTP::Daemon::SSL->new || die;
  print "Please contact me at: <URL:", $d->url, ">\n";
  while (my $c = $d->accept) {
      while (my $r = $c->get_request) {
          if ($r->method eq 'GET' and $r->url->path eq "/xyzzy") {
              # remember, this is *not* recommened practice :-)
              $c->send_file_response("/etc/passwd");
          } else {
              $c->send_error(RC_FORBIDDEN)
          }
      }
      $c->close;
      undef($c);
  }
⚠️ okay but fr fr β€” that "/etc/passwd" bit? do not do that. the comment literally says it's not recommened practice (yes, that's how it's spelled in the source, we're keeping it, character for character, iykyk 😭). serving /etc/passwd is a whole jump-scare. the vibe check says no. πŸ’€

πŸ’– DESCRIPTION πŸ’–

so, instances of the HTTP::Daemon::SSL class? they're literally HTTP/1.1 servers. they sit on a socket, listening for incoming requests, being all mysterious and main character. and here's the slay: HTTP::Daemon::SSL is a sub-class of IO::Socket::SSL, which means you can just… perform socket operations directly on it too. no cap. 🫢

the accept() method returns when a connection from a client is available. in a scalar context, what you get back is a reference to an object of the HTTP::Daemon::ClientConn::SSL class β€” which is, you guessed it, another IO::Socket::SSL subclass. in a list context, you get a two-element array containing the new HTTP::Daemon::ClientConn::SSL reference and the peer address; the list will be empty upon failure. (ngl, a little note from history: version 1.02 erroneously did not honour list context. embarrassing for her, honestly. πŸ™ˆ) calling the get_request() method on the HTTP::Daemon::ClientConn::SSL object will read data from the client and return an HTTP::Request object reference. cute. ✨

okay, important part, bestie, pay attention: this HTTPS daemon does not fork(2) for you. your application β€” i.e. the user of the HTTP::Daemon::SSL β€” is reponsible for forking if that is desirable. (and yes, "reponsible," that's the original spelling, we stan a typo that ate. πŸ˜­πŸ’…) also note that you are responsible for generating responses that conform to the HTTP/1.1 protocol. the HTTP::Daemon::ClientConn class provides some methods that make this easier, so like… use them. 🌈


πŸŽ€ METHODS πŸŽ€

the following methods are the only differences from the HTTP::Daemon base class β€” everything else is inherited, she's just wearing a new outfit:

  • $d = new HTTP::Daemon::SSL β€” the constructor. it takes the same parameters as the IO::Socket::SSL constructor. it can also be called without specifying any parameters, but then you have to make sure you have an SSL certificate and key for the server at certs/server-cert.pem and certs/server-key.pem. see the IO::Socket::SSL documentation for how to change these default locations and specify many other aspects of SSL behavior. the daemon will then set up a listen queue of 5 connections and allocate some random port number. πŸŽ€

a server that wants to bind to some specific address on the standard HTTPS port will be constructed like this:

  $d = new HTTP::Daemon::SSL
        LocalAddr => 'www.someplace.com',
        LocalPort => 443;

look at her go. specific address, standard HTTPS port, absolutely thriving. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

  • RFC 2068
  • IO::Socket::SSL, HTTP::Daemon, Apache

go read them, they're the supporting cast and they understood the assignment. πŸ¦‹


code and documentation from HTTP::Daemon Copyright 1996-2001, Gisle Aas changes Copyright 2003-2004, Peter Behroozi

this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ’œ


πŸ’€ POD ERRORS πŸ’€

Hey! The above document had some coding errors, which are explained below:

  • Around line 164:
You forgot a '=back' before '=head1'

not me exposing the source's whole messy era 😭 but we keep the receipts, that's the rules. πŸ’€


🫢 and that's the page, bestie. no notes. well β€” one note β€” please don't serve /etc/passwd. πŸ™

signing off from perl v5.42.2, dated 2025-11-09 β€” catch you on the next manual page, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from