SSLHandshakeException: certificate_required on HttpsUrlConnection to website

I am trying to access my website using HttpsUrlConnection for an api call from java. I get the following error when trying to run my code: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_required

This does not happen when I test my code from my personal computer running windows. But the error does occur when I run the code from my linux computer, the same computer the website is hosted on. I have my SSL/TLS encryption mode on FULL

Does this mean I have to update something on my linux computer?

	HttpsURLConnection con = null;
	try {
		URL url = new URL("https://www.mydomain.com/api/");
		con = (HttpsURLConnection) url.openConnection();
		con.addRequestProperty("XF-Api-Key", "key");
		con.addRequestProperty("XF-Api-User", "1");
		con.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
		con.setRequestMethod("GET");
		con.setRequestProperty("Content-Type", "application/json");
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
			String inputLine;
			StringBuffer content = new StringBuffer();
			while ((inputLine = in.readLine()) != null)
				content.append(inputLine);
			in.close();

			System.out.println(content.toString());
		} catch (Exception e) {
			e.printStackTrace();
			BufferedReader in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
			String inputLine;
			StringBuffer content = new StringBuffer();
			while ((inputLine = in.readLine()) != null) {
				content.append(inputLine);
			}
			in.close();
			System.out.println(content.toString());
		}
	} catch (Exception exp) {
		System.out.println("Cant load data from API");
		exp.printStackTrace();
	} finally {
		if (con != null)
			con.disconnect();
	}
	return 2;

Hi @kiwiszijncool sorry to know that you’re having difficulties.
There shouldn’t be any difference connecting to a Cloudflare protected site via Linux or Windows via a Java user agent as far as I know. Since you’re running the Java program in the same server that’s running the site, I’m suspecting you might have a local DNS entry for your site which means the request never went out via the public internet but resolves locally, serving the origin SSL certificate instead.
Are you using a self-signed certificate? Do you have the correct hostname included in the SAN of the origin certificate?