in reply to Embed your openssl commands in Perl

The idea of cut'n'paste between Perl and shell is seductive. I know I'm fond of heredocs and SQL. But I wonder if having to use a source filter is worth the pain.

With a bit of infrastructure it wouldn't be hard to produce a more Perlish interface. Consider a skeletal

#! /usr/bin/perl package OpenSSL; use strict; use warnings; use Exporter; use vars qw(@ISA @EXPORT); @ISA = 'Exporter'; @EXPORT = qw(openssl connect in s_client); sub openssl { return bless {}, __PACKAGE__; } sub s_client { my $self = shift; $self->{s_client} = 1; } sub connect { my $self = shift; my $uri = shift; my $cert = frantic_hand_waving($uri); return $cert; } 1;

This lets you write perfectly legal Perl code that looks like:

use OpenSSL; my $cert = openssl->s_client->connect('myhost.com:443');

That would be fine by me. But then again, it's your itch, not mine. I think the idea is definitely worth pursuing one way or another.

update: well DUH! Should have read the opening line a bit more carefully... so there are modules that already do this, more fool me.

That said, I'm sure there must be a way to convince the interpreter that the openssl command line is valid Perl. I'll have to think about it.

• another intruder with the mooring in the heart of the Perl

Replies are listed 'Best First'.
Re^2: Embed your openssl commands in Perl
by Anonymous Monk on Dec 08, 2008 at 18:24 UTC
    It appears that many of the Perl modules that interface to OpenSSL are for the cryptographic aspects, not for the protocol/certificate handling, such as the 's_client' example. So, I agree with your original comments on making the interface more Perlish.