Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

HTTPS for all.api.radio-browser.info #122

Closed
abaldeweg opened this issue Jul 29, 2021 · 2 comments
Closed

HTTPS for all.api.radio-browser.info #122

abaldeweg opened this issue Jul 29, 2021 · 2 comments

Comments

@abaldeweg
Copy link

The tls cert for https://all.api.radio-browser.info does not work for me on Chrome, stating Your connection is not private.

@ivandotv
Copy link

ivandotv commented Aug 31, 2021

Actual error is net::ERR_CERT_COMMON_NAME_INVALID
This makes the API unusable from the frontend (browser).

ivandotv added a commit to ivandotv/radio-browser-api that referenced this issue Aug 31, 2021
Currently API route to resolve servers has a an invalid https certificate
segler-alex/radiobrowser-api-rust#122 untill the issue is resolved, when
module is running in the browser it will use hardcoded server api.

fix 52
@laravieira
Copy link

To leave my experience, I needed HTTPS because my DNS has HSTS enabled, and disabling it is not an option.

This clearly is not a long-term fix, but I don't need that, so I overwrote the main class with:
RadioBrowserApi.overwrite.ts

import {
  RadioBrowserApi as RadioBrowserApiSuper
} from 'radio-browser-api';
import https from 'https';
import axios from 'axios';

type Server = {
  ip: string,
  name: string
};

class RadioBrowserApi extends RadioBrowserApiSuper {
  constructor(appName: string, hideBroken = true) {
    super(appName, hideBroken);
  }

  // temporary fix for https cert error when in frontend hardcode the server
  // https://github.com/segler-alex/radiobrowser-api-rust/issues/122
  async resolveBaseUrl(config: RequestInit = {}): Promise<Server[]> {
    const httpsAgent = new https.Agent({

      rejectUnauthorized: false
    });
    const SERVER_LIST_URL = 'https://de1.api.radio-browser.info/json/servers';

    return axios(SERVER_LIST_URL, { httpsAgent })
      .then(response => response.status === 200 ? response.data : Promise.reject(response.status))
      .then(list => list as Server[])
  }
}

export default RadioBrowserApi;

What I basically did was change the subdomain from all to de1 since the certificate returned on all is for de1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants