2018 twenty four merry days of Perl Feed

Watching The Perl Conference Again

App::HTTPThis and App::HTTPSThis - 2018-12-24

Another year, another successful Christmas Eve. It was time for the Wise Old Elf to pack his bags and head off for his southern-hemisphere summer holiday once again.

This year, like last year, before he left he decided to download a bunch of videos to watch on the beach. What better to entertain himself than the talks from last year's Perl Conference?

Downloading these with Perl was just as easy as last year:

    perl -Mojo -E \
      'g(shift)->dom(".pl-video-title-link")->map(sub{say $_->attr("href")})' \
      'https://www.youtube.com/playlist?list=PLA9_Hq3zhoFx1inHPmwmbXrPcI8cc0fyO' \
      | xargs -n 1 youtube-download

Sharing is Caring

On the beach, Mrs Wiser Elf looked over the Wise Old Elf's shoulder.

"Watcha watching?", she asked.

"The videos from the The Perl Conference in Salt Lake City this year. I'm watching this talk on the relaunching of perl.com."

"Oh! Interesting" she said. Mrs Wiser Elf had been one of the best Perl programmers Santa had had before she'd moved over to designing the custom chipsets that Santa uses in his datacenters.

"I'd love to watch a few of those on my tablet", she continued, "but the bandwidth here is terrible."

"Don't worry my sweet, you can play them right off of my laptop."

The Wise Old Elf had installed App::HTTPThis which would allow him to quickly serve any directory as a website. In the shell The Wise Old Elf changed directory to where he'd downloaded the videos and typed one command:

    bash$ http_this
    Exporting '.', available at:
       http://127.0.0.1:7007/

The Wise Old Elf clicked the link and was greeted by a listing of all the files in his browser.

listing

"Okay my gumdrop, you can head over to http://wiseoldlaptop.local port 7007 to see all the videos"

"I shall do no such thing! What have I always told you about using https these days. Anyone could be snooping on what we're doing."

"Sorry my love".

The Wise Old Elf quickly typed hit ctrl-c to kill the webserver and typed a different command:

    bash$ https_this
    Generating RSA private key, 2048 bit long modulus
    .....+++
    .....................................................................+++
    e is 65537 (0x10001)
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter '.', the field will be left blank.
    -----
    Country Name (2 letter code) []:
    State or Province Name (full name) []:
    Locality Name (eg, city) []:
    Organization Name (eg, company) []:
    Organizational Unit Name (eg, section) []:
    Common Name (eg, fully qualified host name) []:localhost
    Email Address []:

    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:
    Signature ok
    subject=/CN=localhost
    Getting Private key
    2018/12/03-06:11:12 Starman::Server (type Net::Server::PreFork) starting! pid(1130)
    Resolved [*]:8443 to [0.0.0.0]:8443, IPv4
    Binding to SSL port 8443 on host 0.0.0.0 with IPv4
    Setting gid to "20 20 20 12 61 79 80 81 98 701 33 100 204 250 395 398 399"
    Exporting '.', available at:
       https://*:8443/

The App::HTTPSThis module had just automatically created a snake oil certificate, meaning that the connection was encrypted, but still vunerable to man-in-the-middle attacks when the connection was first established - not that that mattered in this case.

"Okay my pecan pie, you can go to https://wiseoldlaptop.local port 8443 now"

And with that, the two elves could get back to taking a well earned rest...until it was time to get ready for next year.

Gravatar Image This article contributed by: Mark Fowler <mark@twoshortplanks.com>