view release on metacpan or search on metacpan
scripts/find-secret-leakage-in-git-diff.pl view on Meta::CPAN
Sometimes you can't put the mark in the same line. Lines beginning private keys,
for example, do not have room for anything else. In these cases you can skip a
whole block marking its beginning and end like this:
## not a secret leak begin
my $rsa_private_key = <<EOS;
-----BEGIN RSA PRIVATE KEY-----
izfrNTmQLnfsLzi2Wb9xPz2Qj9fQYGgeug3N2MkDuVHwpPcgkhHkJgCQuuvT+qZI
MbS2U6wTS24SZk5RunJIUkitRKeWWMS28SLGfkDs1bBYlSPa5smAd3/q1OePi4ae
<...>
8S86b6zEmkser+SDYgGketS2DZ4hB+vh2ujSXmS8Gkwrn+BfHMzkbtio8lWbGw0l
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Git/Libgit2/FFI.pm view on Meta::CPAN
Create a username/password credential.
=head2 git_credential_ssh_key_new
Git::Libgit2::FFI::git_credential_ssh_key_new(\my $cred, $username, $public_key, $private_key, $passphrase);
Create an SSH key credential.
=head2 git_credential_ssh_key_from_agent
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Git/Native/Credential.pm view on Meta::CPAN
}
sub ssh_key {
my ( $class, %args ) = @_;
my $user = $args{username} // Carp::croak "ssh_key: 'username' required";
my $private_key = $args{private_key} // Carp::croak "ssh_key: 'private_key' required";
my $public_key = $args{public_key}; # may be undef â libgit2 derives
my $passphrase = $args{passphrase} // '';
check_rc Git::Libgit2::FFI::git_credential_ssh_key_new(
\my $cred, $user, $public_key, $private_key, $passphrase,
);
return $class->new( _handle => $cred );
}
sub ssh_agent {
lib/Git/Native/Credential.pm view on Meta::CPAN
# explicit key file
my $cred = Git::Native::Credential->ssh_key(
username => 'git',
public_key => "$ENV{HOME}/.ssh/id_ed25519.pub",
private_key => "$ENV{HOME}/.ssh/id_ed25519",
passphrase => '',
);
=head1 DESCRIPTION
lib/Git/Native/Credential.pm view on Meta::CPAN
=head2 ssh_key
Git::Native::Credential->ssh_key(
username => 'git',
private_key => "$ENV{HOME}/.ssh/id_ed25519",
public_key => "$ENV{HOME}/.ssh/id_ed25519.pub", # optional
passphrase => 'hunter2', # optional
);
An on-disk key pair (C<git_credential_ssh_key_new>). C<username> and
C<private_key> are required; C<public_key> may be left out, in which case
libgit2 derives it from the private key, and C<passphrase> defaults to the
empty string. The key files are not touched at construction time â libgit2
reads them when the transport uses the credential, so a wrong path surfaces
as an auth failure during C<fetch> / C<push>, not here.
view all matches for this distribution
view release on metacpan or search on metacpan
t/10-clone.t view on Meta::CPAN
my $ssh_dir = catfile($ENV{HOME}, '.ssh');
ok -e $ssh_dir;
my $public_key = catfile($ssh_dir, 'id_rsa.pub');
my $private_key = catfile($ssh_dir, 'id_rsa');
ok -f $public_key;
ok -f $private_key;
is $user, $ENV{USER};
is $url, $remote_url;
return Git::Raw::Cred -> sshkey(
$user,
$public_key,
$private_key
);
},
'certificate_check' => sub {
my ($cert, $valid) = @_;
$certificate_check_fired = 1;
view all matches for this distribution
view release on metacpan or search on metacpan
if (@$identities) {
# Sanity check to verify identity files are ready to go, and expand relative paths if needed.
my $verified_identities = [];
my $public_key_file = {};
my $private_key_file = {};
foreach my $ident (@$identities) {
if (my @found = agentkeys($ident)) {
foreach (@found) {
push @$verified_identities, $_ if !$public_key_file->{$_}++;
}
}
elsif (-e $ident && -r _ && -s _) {
my $pub = run_output_ignore_err "ssh-keygen", "-y", "-P", "", "-f", $ident;
if ($pub) {
warn localtime().": [$$] $Script: --identity '$ident': Using private key for: $pub";
push @$verified_identities, $ident if !$private_key_file->{$ident}++;
}
elsif ($ident =~ m{^(.+)\.pub$} and -r $1 and $ident = $1) {
redo; # Try again with the NON-".pub" file
}
else {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/GitHub/Apps/Auth.pm view on Meta::CPAN
our $VERSION = "0.04";
use Class::Accessor::Lite (
rw => [qw/token expires installation_id/],
ro => [qw/_furl private_key app_id/],
);
use Carp;
use Crypt::PK::RSA;
use Crypt::JWT qw/encode_jwt/;
lib/GitHub/Apps/Auth.pm view on Meta::CPAN
_lazy { "$self" . "$other" };
};
sub new {
my ($class, %args) = @_;
if (!exists $args{private_key} || !$args{private_key}) {
croak "private_key is required.";
}
if (!exists $args{app_id} || !$args{app_id}) {
croak "app_id is required.";
}
if (!$args{installation_id} && !$args{login}) {
croak "must be set installation_id or login.";
}
my $pk = Crypt::PK::RSA->new($args{private_key});
my $klass = {
private_key => $pk,
installation_id => $args{installation_id},
app_id => $args{app_id},
expires => 0,
_furl => Furl->new,
};
lib/GitHub/Apps/Auth.pm view on Meta::CPAN
iat => time(),
exp => time() + 60,
iss => $self->app_id,
},
alg => "RS256",
key => $self->private_key,
);
return $jwt;
}
lib/GitHub/Apps/Auth.pm view on Meta::CPAN
=head1 SYNOPSIS
use GitHub::Apps::Auth;
my $auth = GitHub::Apps::Auth->new(
private_key => "<filename>", # when read private key from file
private_key => \$pk, # when read private key from variable
app_id => <app_id>,
login => <organization or user>
);
# This method returns the cached token inside an object.
# However, refresh expired token automatically.
lib/GitHub/Apps/Auth.pm view on Meta::CPAN
=head1 CONSTRUCTOR
=head2 new
my $auth = GitHub::Apps::Auth->new(
private_key => "<filename>",
app_id => <app_id>,
installation_id => <installation_id>
);
Constructs an instance of C<GitHub::Apps::Auth> from credentials.
=head3 parameters
=head4 private_key
B<Required: true>
This parameter is a private key of the GitHub Apps.
view all matches for this distribution
view release on metacpan or search on metacpan
eg/service_accounts/reseller.pl view on Meta::CPAN
'https://www.googleapis.com/auth/apps.order'
);
my $auth_driver = Google::API::OAuth2::SignedJWT->new({
service_account_name => '<< service account email here >>',
private_key => "$FindBin::<<private key path here >>",
sub => '<< sub is optional, but can be here... >>',
scopes => join(" ", @scopes)
});
my $response = $service->customers->get((
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/Ads/Common/OAuth2ServiceAccountsHandler.pm view on Meta::CPAN
}";
my $encoded_header = __encode_base64_url($header);
my $encoded_claims = __encode_base64_url($claims);
my $key = $self->get___crypt_module()->new_private_key($file) || return 0;
$key->use_pkcs1_padding();
$key->use_sha256_hash();
my $signature = $key->sign("${encoded_header}.${encoded_claims}");
my $encoded_signature = __encode_base64_url($signature);
lib/Google/Ads/Common/OAuth2ServiceAccountsHandler.pm view on Meta::CPAN
}
# Return the private key string from either the PEM file or JSON file specified.
sub __read_certificate_file {
my $self = shift;
my $private_key;
if (!$self->get_pem_file() and !$self->get_json_file()) {
return 0;
}
lib/Google/Ads/Common/OAuth2ServiceAccountsHandler.pm view on Meta::CPAN
open(MYFILE, $self->get_json_file()) || return 0;
while (<MYFILE>) {
$file_str .= $_;
}
my $json_values = parse_json ($file_str);
$private_key = $json_values->{'private_key'};
$self->set_email_address($json_values->{'client_email'});
close(MYFILE);
}
# PEM File
else {
open(MYFILE, $self->get_pem_file()) || return 0;
while (<MYFILE>) {
$private_key .= $_;
}
close(MYFILE);
}
return $private_key;
}
sub __encode_base64_url($) {
my ($s) = shift;
$s = encode_base64($s);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/Ads/GoogleAds/OAuth2ServiceAccountsHandler.pm view on Meta::CPAN
aud => Google::Ads::GoogleAds::Constants::OAUTH2_BASE_URL . "/token",
exp => $time + 3600,
iat => $time,
sub => $self->get_impersonated_email()
},
$json_key->{private_key},
"RS256"
);
my $response = $self->get___lwp_agent()->post(
Google::Ads::GoogleAds::Constants::OAUTH2_BASE_URL . "/token",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/Auth/DefaultCredentials.pm view on Meta::CPAN
# If no explicit json info was provided, fallback to checking environment variables
my $env = $self->environment;
if ($ENV{GOOGLE_PRIVATE_KEY} && $ENV{GOOGLE_CLIENT_EMAIL}) {
require Google::Auth::ServiceAccountCredentials;
return Google::Auth::ServiceAccountCredentials->new(
private_key => $ENV{GOOGLE_PRIVATE_KEY},
client_email => $ENV{GOOGLE_CLIENT_EMAIL},
scope => $scopes,
%options
);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/BigQuery.pm view on Meta::CPAN
sub new {
my ($class, %args) = @_;
die "undefined client_eamil" if !defined $args{client_email};
die "undefined private_key_file" if !defined $args{private_key_file};
die "not found private_key_file" if !-f $args{private_key_file};
my $self = bless { %args }, $class;
$self->{GOOGLE_API_TOKEN_URI} = 'https://accounts.google.com/o/oauth2/token';
$self->{GOOGLE_API_GRANT_TYPE} = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
if ($self->{private_key_file} =~ /\.json$/) {
open my $in, "<", $self->{private_key_file} or die "can't open $self->{private_key_file} : $!";
my $private_key_json = decode_json(join('', <$in>));
close $in;
$self->{private_key} = $private_key_json->{private_key};
} elsif ($self->{private_key_file} =~ /\.p12$/) {
my $password = "notasecret";
my $pkcs12 = Crypt::OpenSSL::PKCS12->new_from_file($self->{private_key_file});
$self->{private_key} = $pkcs12->private_key($password);
} else {
die "invalid private_key_file format";
}
$self->_auth;
$self->_set_rest_description;
lib/Google/BigQuery.pm view on Meta::CPAN
aud => $self->{GOOGLE_API_TOKEN_URI},
exp => $self->{exp},
iat => $self->{iat},
};
my $jwt = JSON::WebToken::encode_jwt($claim, $self->{private_key}, 'RS256', { type => 'JWT' });
my $response = $self->{ua}->post(
$self->{GOOGLE_API_TOKEN_URI},
{ grant_type => $self->{GOOGLE_API_GRANT_TYPE}, assertion => $jwt }
);
lib/Google/BigQuery.pm view on Meta::CPAN
=head1 SYNOPSIS
use Google::BigQuery;
my $client_email = <YOUR CLIENT EMAIL ADDRESS>;
my $private_key_file = <YOUR PRIVATE KEY FILE>;
my $project_id = <YOUR PROJECT ID>;
# create a instance
my $bq = Google::BigQuery::create(
client_email => $client_email,
private_key_file => $private_key_file,
project_id => $project_id,
);
# create a dataset
my $dataset_id = <YOUR DATASET ID>;
lib/Google/BigQuery.pm view on Meta::CPAN
Create a instance.
my $bq = Google::BigQuery::create(
client_email => $client_email, # required
private_key_file => $private_key_file, # required
project_id => $project_id, # optional
dataset_id => $dataset_id, # optional
scope => \@scope, # optional (default is 'https://www.googleapis.com/auth/bigquery')
version => $version, # optional (only 'v2')
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/Devtools/Cloudbuild/V1/Cloudbuild.pm view on Meta::CPAN
=cut
# === Message: Google::Devtools::Cloudbuild::V1::Cloudbuild::GitHubEnterpriseSecrets ===
# Fields for GitHubEnterpriseSecrets
# Field: private_key_version_name Type: 9 ()
# Field: webhook_secret_version_name Type: 9 ()
# Field: oauth_secret_version_name Type: 9 ()
# Field: oauth_client_id_version_name Type: 9 ()
=pod
lib/Google/Devtools/Cloudbuild/V1/Cloudbuild.pm view on Meta::CPAN
=head1 SYNOPSIS
use Google::Devtools::Cloudbuild::V1::Cloudbuild;
my $msg = Google::Devtools::Cloudbuild::V1::Cloudbuild::GitHubEnterpriseSecrets->new(
private_key_version_name => $value,
);
=head1 FIELDS
=over 4
=item * B<private_key_version_name>
Type: String
=item * B<webhook_secret_version_name>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/Cloud/Sql/V1/CloudSqlResources.pm view on Meta::CPAN
=cut
# === Message: Google::Cloud::Sql::V1::CloudSqlResources::SslCertDetail ===
# Fields for SslCertDetail
# Field: cert_info Type: 11 (.google.cloud.sql.v1.SslCert)
# Field: cert_private_key Type: 9 ()
=pod
=head1 NAME
lib/Google/Cloud/Sql/V1/CloudSqlResources.pm view on Meta::CPAN
=item * B<cert_info>
Type: Message (.google.cloud.sql.v1.SslCert)
=item * B<cert_private_key>
Type: String
=back
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/ContentAPI.pm view on Meta::CPAN
scope => $gapiContentScope,
aud => $gapiTokenURI,
exp => $time + 3660, # max 60 minutes
iat => $time
},
key => \$self->{config}->{private_key},
alg => 'RS256'
);
# 2) Request an access token
#
lib/Google/ContentAPI.pm view on Meta::CPAN
{
"endpoint": "https://www.googleapis.com/content/v2.1",
"merchant_id": "123456789",
"type": "service_account",
"project_id": "content-api-194321",
"private_key_id": "11b8e20c2540c788e98b49e623ae8167dc3e4a6f",
"private_key": "-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----\n",
"client_email": "google@content-api.iam.gserviceaccount.com",
"client_id": "999999999",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Google/SAML/Response.pm view on Meta::CPAN
sub _load_rsa_key {
my $self = shift;
my $key_text = shift;
my $rsa_key = Crypt::OpenSSL::RSA->new_private_key( $key_text );
if ( $rsa_key ) {
$self->{ key_obj } = $rsa_key;
my $big_num = ( $rsa_key->get_key_parameters )[ 1 ];
view all matches for this distribution
view release on metacpan or search on metacpan
ext/channel_credentials.xs view on Meta::CPAN
if ( items % 2 ) {
croak("Expecting a hash as input to channel credentials constructor");
}
// @param string pem_root_certs PEM encoding of the server root certificates
// @param string pem_private_key PEM encoding of the client's private key
// (optional)
// @param string pem_cert_chain PEM encoding of the client's certificate chain
// (optional)
// @return ChannelCredentials The new SSL credentials object
const char* pem_root_certs = NULL;
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
pem_key_cert_pair.private_key = pem_key_cert_pair.cert_chain = NULL;
int i;
for (i = 0; i < items; i += 2 ) {
const char *key = SvPV_nolen(ST(i));
if (!strcmp( key, "pem_root_certs")) {
if (SvOK(ST(i+1)))
pem_root_certs = SvPV_nolen(ST(i+1));
} else if (!strcmp( key, "pem_private_key")) {
if (SvOK(ST(i+1)))
pem_key_cert_pair.private_key = SvPV_nolen(ST(i+1));
} else if (!strcmp( key, "pem_cert_chain")) {
if (SvOK(ST(i+1)))
pem_key_cert_pair.cert_chain = SvPV_nolen(ST(i+1));
}
}
ctx->wrapped = grpc_ssl_credentials_create(
pem_root_certs,
pem_key_cert_pair.private_key == NULL ? NULL : &pem_key_cert_pair, NULL
#ifdef GRPC_SSL_CREDENTIALS_HAS_4_ARGS
, NULL
#endif
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HEAT/Crypto.pm view on Meta::CPAN
use Carp;
use HEAT::Crypto::X25519;
use Crypt::Mode::CBC;
use Exporter qw(import);
our @EXPORT_OK = qw(hash heat_key get_private_key keygen priv_to_pub_key
shared_key sign verify encrypt decrypt account_id random_bytes tohex unhex);
our $VERSION = '0.04';
my $cbc = Crypt::Mode::CBC->new('AES');
lib/HEAT/Crypto.pm view on Meta::CPAN
} else {
croak('invalid key spec: %q', $spec);
}
}
sub get_private_key($)
{
my $spec = shift;
if ($spec =~ /^([a-z]{3,12}( |\Z)){12}$/) {
return HEAT::Crypto::X25519::keyhash($spec);
lib/HEAT/Crypto.pm view on Meta::CPAN
}
}
sub priv_to_pub_key($)
{
my $p = get_private_key($_[0]);
my $r = HEAT::Crypto::X25519::keygen($p);
return tohex($r->{p});
}
sub account_id($)
lib/HEAT/Crypto.pm view on Meta::CPAN
};
}
sub shared_key($$)
{
my $k = get_private_key($_[0]);
my $p = heat_key($_[1]);
return tohex(HEAT::Crypto::X25519::shared($k, $p));
}
sub sign($$)
{
my $k = get_private_key($_[0]);
my $msg = $_[1];
return tohex(HEAT::Crypto::X25519::sign($k, $msg));
}
sub verify($$$)
lib/HEAT/Crypto.pm view on Meta::CPAN
p => <public key bytes>,
k => <private key bytes>,
s => <signing key bytes>,
}
=item shared_key( $private_key, $public_key );
Compute shared secret.
Returns the key as a hexadecimal string.
=item sign( $private_key, $message );
Sign message with the private key.
Returns the signature as a hexadecimal string.
lib/HEAT/Crypto.pm view on Meta::CPAN
Decrypts data with the given key. Data is expected to be returned by encrypt();
It returns the decrypted data on success. This function might die in case of errors.
=item priv_to_pub_key( $private_key )
Derives the public key from the private key.
Returns the public key as a hexadecimal string.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HEAT/Crypto.pm view on Meta::CPAN
p => <public key bytes>,
k => <private key bytes>,
s => <signing key bytes>,
}
=item shared_key( $private_key, $public_key );
Computes shared secret.
Returns the key bytes.
=item sign( $private_key, $message );
Sign message with the private key.
Returns the signature bytes.
lib/HEAT/Crypto.pm view on Meta::CPAN
Decrypts data with the given key. Data is expected to be in the format returned
by encrypt();
It returns the decrypted data on success or undefined in case of failure.
=item priv_to_pub_key( $private_key )
Derives the public key from the private key.
=item account_id( $public_key )
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTML/FormFu/Constraint/reCAPTCHA.pm view on Meta::CPAN
= blessed($query)
&& $query->can('secure')
&& $query->can('address');
my $captcha = Captcha::reCAPTCHA->new;
my $privkey = $self->parent->private_key || $ENV{RECAPTCHA_PRIVATE_KEY};
my $remoteip
= $catalyst_compatible
? $query->address
: $ENV{REMOTE_ADDR};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
our $AUTHORITY = 'cpan:JJNAPIORK';
has '+widget' => ( default => 'reCAPTCHA' );
has '+input_param' => ( default => 'recaptcha_response_field' );
has [qw/public_key private_key/] => (is=>'rw', isa=>'Str', lazy_build=>1);
has 'use_ssl' => (is=>'rw', isa=>'Bool', required=>1, default=>0);
has 'remote_address' => (is=>'rw', isa=>'Str', lazy_build=>1);
has 'recaptcha_options' => (is=>'rw', isa=>'HashRef', required=>1, default=>sub{ +{} });
has 'recaptcha_message' => (is=>'rw', isa=>'Str', default=>'Error validating reCAPTCHA');
has 'recaptcha_instance' => (is=>'ro', init_arg=>undef, lazy_build=>1);
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
} else {
die "You either have to set the 'public_key' field option or defined a $method method in your form!";
}
}
sub _build_private_key {
my $self = shift @_;
my $form = $self->form;
my $method = $self->name.'_private_key';
if ($form->can($method)) {
return $form->$method;
} else {
die "You either have to set the 'private_key' field option or defined a $method method in your form!";
}
}
sub _build_encrypter {
my $self = shift @_;
my $key = pack("H16",$self->private_key);
return Crypt::CBC->new(-key=>$key,-cipher=>"Blowfish");
}
sub _build_remote_address {
$ENV{REMOTE_ADDR};
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
}
sub prepare_private_recaptcha_args {
my $self = shift @_;
return (
$self->private_key,
$self->prepare_recaptcha_args,
);
}
sub prepare_recaptcha_args {
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
In your L<HTML::FormHandler> subclass, "MyApp::HTML::Forms::MyForm":
has_field 'recaptcha' => (
type=>'reCAPTCHA',
public_key=>'[YOUR PUBLIC KEY]',
private_key=>'[YOUR PRIVATE KEY]',
recaptcha_message => "You're failed to prove your Humanity!",
required=>1,
);
Example L<Catalyst> controller:
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
=head2 public_key
The public key you get when you create an account on L<http://recaptcha.net/>
=head2 private_key
The private key you get when you create an account on L<http://recaptcha.net/>
=head2 use_ssl
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
=head1 FORM METHODS
The following methods or attributes can be set in the form which contains the
recapcha field.
=head2 $name_public_key or $name_private_key
"$name" is the name you gave to the reCAPTCHA field (the word directy after the
"has_field" command.
You may wish to set your public key from a method or attribute contained from
within the form. This would make it easier to have one form class and use
configuration tools, such as what L<Catalyst> offers, to set the pubic key.
For example:
## In my form "MyApp::Form::MyForm
has ['MY_recaptcha_public_key', 'MY_recapcha_private_key'] => (
is=>'ro', isa=>'Str', required=>1,
);
has_field 'MY_recaptcha' => (
type=>'reCAPTCHA',
recaptcha_message => "You're failed to prove your Humanity!",
lib/HTML/FormHandlerX/Field/reCAPTCHA.pm view on Meta::CPAN
Then you might construct this in a L<Catalyst::Controller>:
my $form = MyApp::Form::MyForm->new(
MY_recaptcha_public_key => $self->controller_public_key,
MY_recaptcha_private_key => $self->controller_private_key,
);
## 'process', etc.
Then your controller could populate the attributes 'controller_public_key' and
'controller_private_key' from your global L<Catalyst> configuration, allowing
you to use one set of keys in development and another for production, or even
use different keys for different forms if you wish.
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
t/function.t view on Meta::CPAN
is($m->{gpx_js_url}, 'https://my.cdn/gpx.js', 'gpx_js_url overridden');
};
subtest 'new: clone merges overrides, skips validation, is a distinct object' => sub {
my $base = HTML::OSM->new(zoom => 5);
my $clone = $base->new(zoom => 9, _private_key => 'val');
isa_ok($clone, 'HTML::OSM', 'clone isa HTML::OSM');
is($clone->{zoom}, 9, 'clone zoom updated');
is($clone->{height}, $CFG{DEFAULT_HEIGHT}, 'clone inherits height');
is($clone->{_private_key}, 'val', 'arbitrary key passes clone (no validation)');
isnt(refaddr($clone), refaddr($base), 'clone is a distinct reference');
returns_ok($clone, { type => 'object', isa => 'HTML::OSM' }, 'clone returns HTML::OSM');
};
subtest 'new: cache default is an object with get/set' => sub {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/PublicKeyPins.pm view on Meta::CPAN
/^[-]{5}BEGIN[ ](?:RSA[ ])?(PUBLIC|PRIVATE)[ ]KEY[-]{5}/smx )
{
my ($type) = ($1);
if ( $type eq 'PRIVATE' ) {
$pem_encoded_public_key_string =
_process_pem_private_key( $handle, $file_header, $path );
}
else {
$pem_encoded_public_key_string =
_process_pem_public_key( $handle, $file_header, $path );
}
lib/HTTP/PublicKeyPins.pm view on Meta::CPAN
}
else {
$pem_encoded_public_key_string =
_check_for_der_encoded_x509_certificate( $handle, $file_header,
$path )
|| _check_for_der_encoded_private_key( $handle, $file_header, $path )
|| _check_for_der_pkcs10_certificate_request( $handle, $file_header,
$path )
|| _check_for_der_encoded_public_key( $handle, $file_header, $path );
if ( !defined $pem_encoded_public_key_string ) {
Carp::croak("$path is not an X.509 Certificate");
lib/HTTP/PublicKeyPins.pm view on Meta::CPAN
return;
};
return $pem_encoded_public_key_string;
}
sub _check_for_der_encoded_private_key {
my ( $handle, $file_header, $path ) = @_;
my $pem_encoded_public_key_string;
seek $handle, 0, Fcntl::SEEK_SET()
or Carp::croak("Failed to seek to start of $path:$EXTENDED_OS_ERROR");
defined read $handle, my $der_encoded_private_key_string,
_MAX_PUBLIC_KEY_SIZE()
or Carp::croak("Failed to read from $path:$EXTENDED_OS_ERROR");
my $pem_encoded_private_key_string =
"-----BEGIN RSA PRIVATE KEY-----\n"
. MIME::Base64::encode_base64($der_encoded_private_key_string)
. "-----END RSA PRIVATE KEY-----\n";
eval {
my $privkey =
Crypt::OpenSSL::RSA->new_private_key($pem_encoded_private_key_string);
$pem_encoded_public_key_string = $privkey->get_public_key_x509_string();
} or do {
return;
};
return $pem_encoded_public_key_string;
}
sub _process_pem_private_key {
my ( $handle, $file_header, $path ) = @_;
my $pem_encoded_public_key_string;
seek $handle, 0, Fcntl::SEEK_SET()
or Carp::croak("Failed to seek to start of $path:$EXTENDED_OS_ERROR");
defined read $handle, my $rsa_private_key_string, _MAX_PUBLIC_KEY_SIZE()
or Carp::croak("Failed to read from $path:$EXTENDED_OS_ERROR");
my $privkey = Crypt::OpenSSL::RSA->new_private_key($rsa_private_key_string);
$pem_encoded_public_key_string = $privkey->get_public_key_x509_string();
return $pem_encoded_public_key_string;
}
sub _process_pem_public_key {
view all matches for this distribution
view release on metacpan or search on metacpan
include/hyperman/hm_tls.h view on Meta::CPAN
}
if (SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM) <= 0) {
fprintf(stderr, "Hyperman TLS: cannot load private key '%s'\n", key);
ERR_print_errors_fp(stderr); SSL_CTX_free(ctx); return NULL;
}
if (!SSL_CTX_check_private_key(ctx)) {
fprintf(stderr, "Hyperman TLS: certificate and key do not match\n");
SSL_CTX_free(ctx); return NULL;
}
#ifdef HM_HAVE_ALPN
/* h3 only on a QUIC context: offering h2 or http/1.1 over QUIC is a
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Hypersonic/TLS.pm view on Meta::CPAN
->line(' g_ssl_ctx = NULL;')
->line(' return -3;')
->line(' }')
->line('')
->line(' /* Verify private key matches certificate */')
->line(' if (!SSL_CTX_check_private_key(g_ssl_ctx)) {')
->line(' SSL_CTX_free(g_ssl_ctx);')
->line(' g_ssl_ctx = NULL;')
->line(' return -4;')
->line(' }')
->line('')
lib/Hypersonic/TLS.pm view on Meta::CPAN
g_ssl_ctx = NULL;
return -3;
}
/* Verify private key matches certificate */
if (!SSL_CTX_check_private_key(g_ssl_ctx)) {
SSL_CTX_free(g_ssl_ctx);
g_ssl_ctx = NULL;
return -4;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/IBM/SONAS.pm view on Meta::CPAN
# Create an IBM::SONAS object
my $ibm = IBM::SONAS->new(
user => 'admin',
host => 'my-sonas.company.com',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
=head1 METHODS
=head3 new ( %ARGS )
my $ibm = IBM::SONAS->new(
user => 'admin',
host => 'my-sonas.company.com',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
Constructor - creates a new IBM::SONAS object. This method accepts three
mandatory parameters and one optional parameter, the three mandatory
parameters are:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/IBM/StorageSystem.pm view on Meta::CPAN
# Create a IBM::StorageSystem object
my $ibm = IBM::StorageSystem->new(
user => 'admin',
host => 'my-StorageSystem',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
# Get a list of our enclosures as IBM::StorageSystem::Enclosure objects
my @enclosures = $ibm->get_enclosures;
lib/IBM/StorageSystem.pm view on Meta::CPAN
=head3 new
my $ibm = IBM::StorageSystem->new(
user => 'admin',
host => 'my-StorageSystem',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
Constructor - creates a new IBM::StorageSystem object. This method accepts three mandatory parameters
and one optional parameter, the three mandatory parameters are:
lib/IBM/StorageSystem.pm view on Meta::CPAN
use Date::Calc qw(date_to_Time Today_and_Now);
my $ibm = IBM::StorageSystem->new(
user => 'admin',
host => 'my-v7000',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
# Generate an alert for any replication errors in the last six hours
foreach my $task ( $ibm->get_replications ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/IBM/V7000.pm view on Meta::CPAN
=head3 new
my $ibm = IBM::V7000->new( user => 'admin',
host => 'my-v7000.company.com',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
Constructor - creates a new IBM::V7000 object. This method accepts three mandatory parameters
and one optional parameter, the three mandatory parameters are:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/IBM/V7000Unified.pm view on Meta::CPAN
=head3 new
my $ibm = IBM::V7000Unified->new(
user => 'admin',
host => 'my-v7000-unified.company.com',
key_path => '/path/to/my/.ssh/private_key'
) or die "Couldn't create object! $!\n";
Constructor - creates a new IBM::V7000Unified object. This method accepts
three mandatory parameters and one optional parameter, the three mandatory
parameters are:
view all matches for this distribution
view release on metacpan or search on metacpan
ex/crypto.pl view on Meta::CPAN
#note that this code will not work exactly as written, because it needs
#to run on two different boxes.
my ($sender_public_key, $sender_private_key) = IPC::Transit::gen_key_pair();
my ($receiver_public_key, $receiver_private_key) = IPC::Transit::gen_key_pair();
$IPC::Transit::my_hostname = 'sender.hostname.com';
$IPC::Transit::my_keys->{public} = $sender_public_key;
$IPC::Transit::my_keys->{private} = $sender_private_key;
$IPC::Transit::public_keys->{'receiver.hostname.com'} = $receiver_public_key;
IPC::Transit::send(
message => {foo => 'bar'},
ex/crypto.pl view on Meta::CPAN
#teleport over to the receiver, magically using keys generated above
$IPC::Transit::my_hostname = 'receiver.hostname.com';
$IPC::Transit::my_keys->{public} = $receiver_public_key;
$IPC::Transit::my_keys->{private} = $receiver_private_key;
$IPC::Transit::public_keys->{'sender.hostname.com'} = $sender_public_key;
my $message = IPC::Transit::receiver(
qname => 'some_qname'
);
view all matches for this distribution