Skip to content

Commit ebc8a18

Browse files
committed
Dispatcher::resolve_uri - fix case with explicit transport
Socketpool: better debug output for certificates
1 parent b7b8c92 commit ebc8a18

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lib/Net/SIP/Dispatcher.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ use constant SRV_PRIO_UNDEF => -1;
5656
# with special domain '*' a default can be specified, so that DNS
5757
# will not be used at all
5858
# dnsresolv: DNS resolver function with interface sub->(type,domain,callback)
59-
# which then calls callback->([{ prio, host, addr, port, family }])
59+
# which then calls callback->(\@result) with @result being a list of
60+
# [ 'SRV',prio,target,port], ['A',ip,name], ['AAAA',ip,name]
6061
# Returns: $self
6162
###########################################################################
6263
sub new {
@@ -747,7 +748,7 @@ sub resolve_uri {
747748
}
748749

749750
# should we use a fixed transport?
750-
if ( my $proto = $param->{transport} ) {
751+
if (@resp and my $proto = $param->{transport} ) {
751752
$proto = lc($proto);
752753
if ($proto eq 'udp') {
753754
@resp = grep { $_->{proto} eq 'udp' } @resp

lib/Net/SIP/SocketPool.pm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,10 @@ sub _tls_accept {
653653

654654
if ($fo->{fd}->accept_SSL()) {
655655
if ($DEBUG) {
656-
my $peer_cert = $fo->{fd}->dump_peer_certificate()
657-
|| 'no peer certificate';
658-
DEBUG(40,"TLS accept success, peer=$peer_cert");
656+
my $peer_cert = $fo->{fd}->peer_certificate;
657+
DEBUG(40,"TLS accept success, %s", $peer_cert
658+
? "peer="._dump_certificate($peer_cert)
659+
: 'no peer certificate');
659660
}
660661
delete $fo->{inside_connect};
661662
$self->{loop}->delFD($xxfd, EV_WRITE) if $xxfd;
@@ -695,7 +696,7 @@ sub _tls_connect {
695696

696697
if ($fo->{fd}->connect_SSL()) {
697698
$DEBUG && DEBUG(40,"TLS connect success peer cert=%s",
698-
$fo->{fd}->dump_peer_certificate());
699+
_dump_certificate($fo->{fd}->peer_certificate));
699700
delete $fo->{inside_connect};
700701
$self->{loop}->delFD($xxfd, EV_WRITE) if $xxfd;
701702
_addreader2loop($self,$fo);
@@ -722,4 +723,11 @@ sub _tls_connect {
722723
}
723724

724725

726+
sub _dump_certificate {
727+
my $cert = shift or return '';
728+
my $issuer = Net::SSLeay::X509_NAME_oneline( Net::SSLeay::X509_get_issuer_name($cert));
729+
my $subject = Net::SSLeay::X509_NAME_oneline( Net::SSLeay::X509_get_subject_name($cert));
730+
return "s:$subject i:$issuer";
731+
}
732+
725733
1;

0 commit comments

Comments
 (0)