Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^15: Unable to enable SSL on Dancer2 application in my windows platform.

by chandantul (Scribe)
on May 06, 2021 at 01:58 UTC ( [id://11132117]=note: print w/replies, xml ) Need Help??


in reply to Re^14: Unable to enable SSL on Dancer2 application in my windows platform.
in thread Unable to enable SSL on Dancer2 application in my windows platform.

Hello Smart monks, Did you enable SSL on the app by Self signed certificate for the Dancer2 Apps? If its so, please provide me the steps. I have created Self-signed certificate and imported the same in my Java keystore and defined them in the command as per the required parameters but its still giving error.

C:\Users\Documents\Perl\webapp\bin>plackup -p 5001 --ssl --ssl-key-fil +e=C:\Users\Documents\Private-Public-key-cert\Private0504.key --ssl-ce +rt-file=C:\Users\Documents\Private-Public-key-cert\Cert.crt --ca_file +=C:\Users\Documents\Private-Public-key-cert\cacerts --ssl_fingerprint +=sha1$B151CE74BC550FF4FF173266B906F0FCF45FFCEB app.psgi [webapp:9108] core @2021-05-05 21:36:01> Built config from files: C:\U +sers\Documents\Perl\webapp\config.yml C:\Users\Documents\Perl\webapp\ +environments\development.yml in (eval 272) l. 910 failed to listen to port 5001: at C:/Strawberry/perl/site/lib/HTTP/Se +rver/PSGI.pm line 103..

Have created SSL testing tools but its giving "No Socket" error

use strict; use warnings; #use IO::Socket::SSL::DEBUG::3; use IO::Socket::SSL qw(debug3); use Net::SSLeay; # simple server my $server = IO::Socket::SSL->new( # where to listen #PeerAddr => '192.168.1.8:5061', LocalAddr => '127.0.0.1', # LocalPort => '5001', Listen => '5001', # which certificate to offer # with SNI support there can be different certificates per hostnam +e #verify_mode => Net::SSLeay->VERIFY_PEER(), SSL_cert_file => 'C:/Users/Documents/Private-Public-key-cert/Cert. +crt', SSL_key_file => 'C:/Users/Documents/Private-Public-key-cert/Privat +e0504.key', SSL_fingerprint => 'sha1$B151CE74BC550FF4FF173266B906F0FCF45FFCEB' +, ca_file => 'C:/Users/Documents/Private-Public-key-cert/cacerts', ) or die "failed to listen: $!"; # accept client my $client = $server->accept or die "failed to accept or ssl handshake: $!,$SSL_ERROR";

Its giving below but not able to find the exact error after DABUG3

use strict; use warnings; #use IO::Socket::SSL::DEBUG::3; use IO::Socket::SSL qw(debug3); use Net::SSLeay; # simple server my $server = IO::Socket::SSL->new( # where to listen #PeerAddr => '192.168.1.8:5061', LocalAddr => '127.0.0.1', # LocalPort => '5001', Listen => '5001', # which certificate to offer # with SNI support there can be different certificates per hostnam +e #verify_mode => Net::SSLeay->VERIFY_PEER(), SSL_cert_file => 'C:/Users/Documents/Private-Public-key-cert/Cert. +crt', SSL_key_file => 'C:/Users/Documents/Private-Public-key-cert/Privat +e0504.key', SSL_fingerprint => 'sha1$B151CE74BC550FF4FF173266B906F0FCF45FFCEB' +, ca_file => 'C:/Users/Documents/Private-Public-key-cert/cacerts', ) or die "failed to listen: $!"; # accept client my $client = $server->accept or die "failed to accept or ssl handshake: $!,$SSL_ERROR";

Please help if its possible.

Replies are listed 'Best First'.
Re^16: Unable to enable SSL on Dancer2 application in my windows platform.
by afoken (Chancellor) on May 06, 2021 at 11:12 UTC
    Have created SSL testing tools but its giving "No Socket" error

    Did you actually read the code?

    package IO::Socket::SSL; our $VERSION = '2.070'; ##### about a thousand lines omitted ##### #Call to accept occurs when a new client connects to a server using #IO::Socket::SSL sub accept { my $self = shift || return _invalid_object(); my $class = shift || 'IO::Socket::SSL'; my $socket = ${*$self}{'_SSL_opening'}; if ( ! $socket ) { # underlying socket not done $DEBUG>=2 && DEBUG('no socket yet' ); + ##### <--- this is line 1031 ##### $socket = $self->SUPER::accept($class) || return; $DEBUG>=2 && DEBUG('accept created normal socket '.$socket ); # don't continue with accept_SSL if SSL_startHandshake is set +to 0 my $sh = ${*$self}{_SSL_arguments}{SSL_startHandshake}; if (defined $sh && ! $sh) { ${*$socket}{_SSL_ctx} = ${*$self}{_SSL_ctx}; ${*$socket}{_SSL_arguments} = { %{${*$self}{_SSL_arguments}}, SSL_server => 0, }; $DEBUG>=2 && DEBUG('will not start SSL handshake yet'); return wantarray ? ($socket, getpeername($socket) ) : $soc +ket } } $self->accept_SSL($socket) || return; $DEBUG>=2 && DEBUG('accept_SSL ok' ); return wantarray ? ($socket, getpeername($socket) ) : $socket; }

    "no socket yet" is not an error message. If it was, processing would abort, either by returning an error value or by die()ing. It is a diagnostic message to get a clue about which code is currently executing. Line 1031 was executed, now look what happens next: call the accept() method of the parent class, and either return (on error) or continue. accept() may block, given no output at all, and your program appears to hang. According to what you posted so far, that does not happen, so you should get the next diagnostic message from line 1033 ("accept created normal socket"). You did not post that line, so my guess is that $self->SUPER::accept($class) returned a false value and || return; in line 1032 was executed.

    So, think about how you got to line 1031 and why $self->SUPER::accept($class) returned a false value.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Thanks Alaxander, Please check below code that i have written for testing SSL

      use strict; use warnings; #use IO::Socket::SSL::DEBUG::3; use IO::Socket::SSL qw(debug3); use Net::SSLeay; # simple server my $server = IO::Socket::SSL->new( # where to listen PeerAddr => '127.0.0.1:5061', #LocalAddr => '127.0.0.1', #LocalPort => 5001, #Listen => 10, # which certificate to offer # with SNI support there can be different certificates per hostnam +e verify_mode => Net::SSLeay->VERIFY_PEER(), SSL_cert_file => 'C:/Users/Documents/Private-Public-key-cert/Cert. +crt', SSL_key_file => 'C:/Users/Documents/Private-Public-key-cert/Privat +e0504.key', SSL_fingerprint => 'sha1$B151CE74BC550FF4FF173266B906F0FCF45FFCEB' +, ca_file => 'C:/Users/Documents/Private-Public-key-cert/cacerts', ) or die "failed to listen: $!"; # accept client my $client = $server->accept or die "failed to accept or ssl handshake: $!,$SSL_ERROR"; IO::Socket::SSL->start_SSL($client, SSL_server => 1, ) or die "failed to ssl handshake: $SSL_ERROR";

      Please check below output.is this indicating my Self-Signed certificate is not working?

      DEBUG: .../IO/Socket/SSL.pm:3010: new ctx 50401584 DEBUG: .../IO/Socket/SSL.pm:762: socket not yet connected DEBUG: .../lib/IO/Socket.pm:50: local error: IO::Socket::IP configurat +ion failed DEBUG: .../IO/Socket/SSL.pm:3059: free ctx 50401584 open=50401584 DEBUG: .../IO/Socket/SSL.pm:3063: free ctx 50401584 callback DEBUG: .../IO/Socket/SSL.pm:3070: OK free ctx 50401584 failed to listen: Bad file descriptor at SSL-cert-check2.pl line 9.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132117]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found