Author Topic: How to diagnose / fix BASS_ERROR_SSL problem  (Read 772 times)

SteveS

  • Posts: 22
Hi

I have a problem which is confusing me more than somewhat.
I have code that calls BASS_Init successfully, and I then load the libbass_aac.so plugin successfully.
So far, so good.

I call
BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1)
BASS_CreateStreamURL(URL, 0, BASS_STREAM_BLOCK,NULL,NULL)

For an http stream, this works (where the URL is valid) and I can then play the stream.
However, I have an https stream which consistently returns BASS_ERROR_SSL.

This is on a Raspberry Pi 4B running 64-bit bookworm, so with the aarch64 libraries.

Now, if I paste the URL into Chromium (the browser), it plays back (it is the URL for a 'ADTS' stream), so I know the URL is a valid resource.

According to the documentation, it will look for the OpenSSL library and expect it to be named:
libssl.so, libssl.so.1.1, libssl.so.10, or libssl.so.1.0.0

I have no files with this name, I do have libssl3.so and libssl.so.3 in /lib/aarch64-linux-gnu.

I tried calling BASS_SetConfigPtr(BASS_CONFIG_LIBSSL, (void*)path) where path is the full path of the ssl shared library, which succeeded, but I still get the same error.

Is there anything I can do to get a more specific indication of why it doesn't work for https streams?

An example of a URL that is causing issues is https://icecast.walmradio.com:8443/jazz


Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: How to diagnose / fix BASS_ERROR_SSL problem
« Reply #1 on: 15 May '24 - 13:25 »
Here's an update that will also look for "libssl.so.3".

   www.un4seen.com/stuff/bass-linux.zip

If you still have the problem with it, please use the "lsof" command to check what files/libraries your app has open after the failed BASS_CreateStreamURL call, and see if a "libssl" is in there.

SteveS

  • Posts: 22
Re: How to diagnose / fix BASS_ERROR_SSL problem
« Reply #2 on: 15 May '24 - 14:52 »
Hi Ian

I have some more information, following an inspiration.

I ran wget to get a picture of what was going on "normally", and the first thing that happened was a redirection (302 Found) which gave a different URL (on a different server), and then it proceeded to get the stream (which, being wget and it being a ADTS source, I had sent the output to /dev/null).

So, I made a note of the redirection URL and tried that directly from BASS, which worked, without me telling it where the SSL library was.
I then crafted a bit of code using libcpr as follows:

bool redirected(std::string& url)
{
    cpr::Response r = cpi::Get(cpr::Url{url.c_str()}, cpr::Redirect{-1,false,true,cpr::PostRedirectFlags::POST_ALL});
    if (r.status_code==302)
    {
        url = r.header["Location"];
        return true;
     }
     return false;
}

This essentially does a GET but won't follow any redirection, so I can see what's happened, and replaces the url with the new one.
Now, in the regular code, I do
 
      hStream = BASS_StreamCreateURL( url.c_str(), 0, BASS_STREAM_BLOCK,NULL, NULL);
      if (hStream == 0 && BASS_ErrorGetCode() == BASS_ERROR_SSL)
      {
            if (redirected(url))
            {
                 hStream = BASS_StreamCreateURL( url.c_str(), 0, BASS_STREAM_BLOCK,NULL, NULL);
            }
       }
       if (hStream == 0)
       {
            // Previous error handling....
       }

This has fixed the issue for me, so now I need to work out what impact this has on my "packaging" when I install the player onto my machines. Normally I just had to make sure libbass.so and libbass_aac.so were available, but suddenly I have a few more dependencies.

Obviously, I don't know what you are doing under the lid for BASS_StreamCreateURL() for SSL requests and response handling, but I hope this gives you more to go on if you want to buld this functionality in.

Regards
Steve

Ian @ un4seen

  • Administrator
  • Posts: 26177
Re: How to diagnose / fix BASS_ERROR_SSL problem
« Reply #3 on: 15 May '24 - 16:07 »
Having now tried the posted URL, it looks like the problem in this case is that the server is blocking BASS clients (presumably because the admin thinks it's a stream ripper), as changing the "User-Agent" via BASS_CONFIG_NET_AGENT gets it working. For example:

Code: [Select]
BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, "MyApp/1.0");

Let me know if it still isn't working for you even then.

SteveS

  • Posts: 22
Re: How to diagnose / fix BASS_ERROR_SSL problem
« Reply #4 on: 15 May '24 - 18:06 »
It works, providing I have an agent string which has 'xxxx/1.0' where xxxx is any string with no space in it.
Works on other URLs too,

Doh!  As you say, BASS/2.x is obviously being discriminated against.

Thanks for this; in summary, I changed my code so that the user agent is set, and removed all the other "tweaks" I had put in, so the original libraries I was using all work fine, which I have come to expect :) and I don't need to package any additional files into my local install packs.

Regards
Steve