<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#! /usr/bin/perl
#
#       Name:         ntripclient.pl
#       Authors:      Dirk Stöcker
#       Description:  perl script to access casters using HTTP and HTTPS

use strict;
#use warnings;
#no warnings "uninitialized";
use MIME::Base64;
use Net::HTTP;
use Net::HTTPS;
use Net::SSLeay;
use IO::Handle;
STDOUT-&gt;autoflush(1);

my $user = "...";
my $pwd = "...";

#getstream("ntrip.dgpsonline.eu", 80, "http", $user, $pwd, "WILD_RTK");
#getstream("ntrip.dgpsonline.eu", 2101, "http", $user, $pwd, "WILD_RTK");
getstream("ntrip.dgpsonline.eu", 443, "https", $user, $pwd, "WILD_RTK");

sub printcert
{
  my $cert = $_[0];
  return $cert;
};

sub getstream
{
  my ($server, $port, $protocol, $user, $pwd, $mp) = @_;
  eval
  {
    local $SIG{ALRM} = sub { die "alarm"; };
    alarm(20);
    my $s;
    if($protocol eq "https")
    {
      $s = Net::HTTPS-&gt;new(Host =&gt; "$server:$port", Timeout =&gt; 10);
      if($s)
      {
        print "Cipher:  ".$s-&gt;get_cipher()."\n";
        my $cert = $s-&gt;get_peer_certificate();
        print "Time:    ".$cert-&gt;not_before() . " to " . $cert-&gt;not_after(). "\n";
        print "Subject: ".printcert($cert-&gt;subject_name())."\n";
        print "Issuer:  ".printcert($cert-&gt;issuer_name())."\n";
        print "\n";
      }
    }
    else
    {
      $s = Net::HTTP-&gt;new(Host =&gt; "$server:$port", Timeout =&gt; 10);
    }
    if($s)
    {
      $s-&gt;write_request(GET =&gt; "/$mp", 'Host' =&gt; "$server:$port", Timeout =&gt; 10,
      'User-Agent' =&gt; "NTRIP ssltestclient.pl/1.0",
      "Ntrip-Version" =&gt; 'Ntrip/2.0',
      ($user ? ("Authorization" =&gt; "Basic " . encode_base64("$user:$pwd")) : ())
      );
      my ($code, $message, %headers) = $s-&gt;read_response_headers;
      print "$code $message\n";
      foreach my $s (keys %headers)
      {
        print "$s: $headers{$s}\n";
      }
      print("\n");
      if($code == 200)
      {
        while(1)
        {
          alarm(10);
          my $n;
          my $buf;
          {
            $n = $s-&gt;read_entity_body($buf, 1024);
          }
          last unless $n;
          print $buf;
        }
      }
      else
      {
        while(1)
        {
          my $buf;
          my $n = $s-&gt;read_entity_body($buf, 1024);
          last unless $n;
          print $buf;
        }
      }
    }
  };
}
</pre></body></html>