# SSL certificate problem: unable to get local issuer certificate

**URL:** <https://forum.infinityfree.com/t/ssl-certificate-problem-unable-to-get-local-issuer-certificate/100363>\
**Category:** Hosting Support\
**Created:** [October 19, 2024, 5:24am UTC](https://forum.infinityfree.com/t/ssl-certificate-problem-unable-to-get-local-issuer-certificate/100363 "2024-10-19T05:24:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuperGamer474](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/supergamer474/32/50650_2.png) [@SuperGamer474](https://forum.infinityfree.com/u/SuperGamer474)\
**Post date:** [October 19, 2024, 5:24am UTC](https://forum.infinityfree.com/t/ssl-certificate-problem-unable-to-get-local-issuer-certificate/100363/1 "2024-10-19T05:24:50Z")

</div>

### Website URL

[https://supergamer474.rf.gd/tools/html-url](https://supergamer474.rf.gd/tools/html-url)  
cURL link: [https://short-links.rf.gd](https://short-links.rf.gd) (Specifically [https://short-links.rf.gd/create.php?long-url=base64-encoded-url&custom-ending=custom](https://short-links.rf.gd/create.php?long-url=base64-encoded-url&custom-ending=custom))

### Error Message

Error while shortening the URL: SSL certificate problem: unable to get local issuer certificate

### Other Information

**html-url.php**

```php
<?php
// Allow requests from any origin
header("Access-Control-Allow-Origin: *");

// Optional: Allow specific HTTP methods (GET, POST, etc.)
header("Access-Control-Allow-Methods: GET, POST");

// Optional: Allow specific headers
header("Access-Control-Allow-Headers: Content-Type, Authorization");

// Optional: For preflight requests (OPTIONS method)
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    header("HTTP/1.1 200 OK");
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML to URL Converter</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background-color: #f0f2f5;
            color: #333;
        }

        header {
            background-color: #1a73e8;
            padding: 20px;
            text-align: center;
            color: white;
        }

        h1 {
            margin: 0;
            font-size: 24px;
        }

        main {
            padding: 40px 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        section {
            width: 100%;
            max-width: 1000px;
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 10px;
            font-weight: bold;
        }

        textarea, input[type="url"], input[type="file"] {
            width: 100%;
            padding: 10px;
            font-size: 16px;
            border: 1px solid #ddd;
            border-radius: 5px;
            margin-bottom: 15px;
        }

        input[type="file"] {
            padding: 5px;
        }

        button {
            width: 100%;
            max-width: 300px;
            padding: 12px;
            background-color: #1a73e8;
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 18px;
            cursor: pointer;
            margin-top: 20px;
        }

        button:hover {
            background-color: #155bb5;
        }

        .output {
            width: 100%;
            padding: 15px;
            background-color: #e6f4ea;
            border: 1px solid #d4edda;
            border-radius: 5px;
            word-wrap: break-word;
            cursor: pointer;
            font-family: monospace;
        }

        .error {
            color: red;
            margin-top: 10px;
        }
    </style>
</head>
<body>

<header>
    <h1>HTML to URL Converter</h1>
</header>

<main>
    <section>
        <label for="htmlInput">Paste HTML Code:</label>
        <textarea id="htmlInput" rows="6" placeholder="Paste your HTML code here..."></textarea>
    </section>

    <section>
        <label for="fileInput">Upload HTML File:</label>
        <input type="file" id="fileInput" accept=".html">
    </section>

    <section>
        <label for="urlInput">Enter URL:</label>
        <input type="url" id="urlInput" placeholder="Enter URL (e.g., https://example.com)">
    </section>

    <button onclick="generateURL()">Generate Base64 URL (URL Works Offline)</button><br>
    <button onclick="generateAndShorten()">Generate Base64 URL & Shorten (URL Requires Internet)</button><br>

    <div class="output" id="output" onclick="copyToClipboard()">Click to copy Base64 URL</div>

    <div class="error" id="error"></div>
</main>

<script>
async function generateURL() {
    const htmlInput = document.getElementById('htmlInput').value;
    const fileInput = document.getElementById('fileInput').files[0];
    const urlInput = document.getElementById('urlInput').value;
    const output = document.getElementById('output');
    const error = document.getElementById('error');

    output.textContent = ''; // Clear previous output
    error.textContent = ''; // Clear previous errors

    try {
        let base64;
        if (htmlInput) {
            // If HTML code is inputted directly
            base64 = encodeToBase64(htmlInput);
        } else if (fileInput) {
            // If an HTML file is uploaded
            const reader = new FileReader();
            reader.onload = function(event) {
                const content = event.target.result;
                base64 = encodeToBase64(content);
                output.textContent = `data:text/html;base64,${base64}`;
            };
            reader.readAsText(fileInput);
            return; // Ensure we exit early while reading the file
        } else if (urlInput) {
            // Fetch the HTML content from the provided URL
            const response = await fetch(urlInput);
            if (!response.ok) throw new Error('Unable to fetch content. Check the URL.');
            const content = await response.text();
            base64 = encodeToBase64(content);
        } else {
            error.textContent = 'Please enter HTML code, upload a file, or provide a URL.';
            return; // Exit if no input is provided
        }
        
        // Set the output with the generated Base64 URL
        output.textContent = `data:text/html;base64,${base64}`;
    } catch (err) {
        error.textContent = `Error: ${err.message}`;
    }
}

async function generateAndShorten() {
    const output = document.getElementById('output');
    const error = document.getElementById('error');
    const customEnding = prompt("Enter a custom ending for the shortened URL:");

    if (!customEnding) {
        error.textContent = 'Custom ending is required.';
        return;
    }

    // Ensure output contains a valid Base64 URL
    const base64Url = output.textContent;

    // Check if the output starts with 'data:text/html;base64,' and is valid
    if (!base64Url.startsWith('data:text/html;base64,')) {
        error.textContent = 'Please generate a valid Base64 URL first.';
        return;
    }

    try {
        const response = await fetch('generateandshorten.php', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: new URLSearchParams({
                base64Url: base64Url, // Send the entire data URL
                customEnding: customEnding
            }).toString() // Ensures correct format
        });

        if (!response.ok) throw new Error('Error while shortening the URL.');

        const result = await response.text(); // Expect a plain text response

        // Replace &amp; with & in the shortened URL before displaying
        const cleanedUrl = result;
        output.textContent = cleanedUrl; // Show the shortened URL
    } catch (err) {
        error.textContent = `Error: ${err.message}`;
    }
}

function encodeToBase64(str) {
    return btoa(unescape(encodeURIComponent(str)));
}

function copyToClipboard() {
    const output = document.getElementById('output');
    const range = document.createRange();
    range.selectNode(output);
    window.getSelection().removeAllRanges();
    window.getSelection().addRange(range);
    
    // Copy the highlighted text
    document.execCommand('copy');
    
    // Alert user that the text has been copied
    alert('Copied to clipboard!');
}
</script>

</body>
</html>

```

**generateandshorten.php**

```php
<?php

// Allow requests from any origin
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST");

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Get data from the POST request
    $base64Url = $_POST['base64Url'] ?? null;
    $customEnding = $_POST['customEnding'] ?? null;

    // Validate input
    if (!$base64Url) {
        echo 'Error: Base64 URL is required';
        exit();
    }

    if (!$customEnding) {
        echo 'Error: Custom ending is required';
        exit();
    }

    // Remove any &amp; from the base64Url and customEnding
    $base64Url = str_replace('&amp;', '&', $base64Url);
    $customEnding = str_replace('&amp;', '&', $customEnding);

    // Construct the full URL for shortening
    $shortenUrl = 'https://short-links.rf.gd/create.php?long-url=' . urlencode($base64Url) . '&custom-ending=' . urlencode($customEnding);

    // Debugging output: Uncomment to see the constructed URL
    // error_log("Shorten URL: " . $shortenUrl);

    // Use curl to fetch the shortened URL
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $shortenUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects if any
    curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Set a timeout

    $shortenedUrl = curl_exec($ch);
    
    if (curl_errno($ch)) {
        // Capture the error using curl
        echo 'Error while shortening the URL: ' . curl_error($ch);
    } else {
        // Remove HTML tags from the shortened URL response
        $cleanedUrl = strip_tags($shortenedUrl);

        // Return the cleaned shortened URL as a plain string
        echo $cleanedUrl;
    }

    curl_close($ch);
}
?>

```

---

<div class="post-metadata">

**Author:** ![KangJL](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/kangjl/32/12130_2.png) [@KangJL](https://forum.infinityfree.com/u/KangJL)\
**Post date:** [October 19, 2024, 5:44am UTC](https://forum.infinityfree.com/t/ssl-certificate-problem-unable-to-get-local-issuer-certificate/100363/2 "2024-10-19T05:44:42Z")

</div>

Sounds like this

> [@SSL checker shows "certificate not trusted" warning](https://forum.infinityfree.com/t/warning-the-certificate-is-not-trusted-in-all-web-browsers/49697/):
>
> When you check your InfinityFree SSL certificate with online SSL checker tools, you might see a warning like this: The certificate is not trusted in all web browsers. You may need to install an Intermediate/chain certificate to link it to a trusted root certificate. This warning sounds scary, but it’s actually not a problem for your website visitors. What this warning means for your site You can safely ignore this warning. Your site will work perfectly fine with HTTPS for virtually all mode…

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [October 19, 2024, 9:56am UTC](https://forum.infinityfree.com/t/ssl-certificate-problem-unable-to-get-local-issuer-certificate/100363/3 "2024-10-19T09:56:41Z")

</div>

It’s that, but more importantly, it’s this:

> [@Ensuring only web browsers can access your website](https://forum.infinityfree.com/t/ensuring-only-web-browsers-can-access-your-website/49353):
>
> InfinityFree is a website hosting service. That means that the hosting accounts we provided are intended for hosting websites. Websites contain pages that are accessed through web browsers. InfinityFree is not intended to be used for file sharing, API hosting, database hosting or background tasks/tools. To help enforce this, free hosting enforces a security system that makes sure that anyone trying to access your website is using a normal web browser. This is done by checking whether the web br…

Also, please note that URL shorteners are frowned upon on our hosting. Spammers love using URL shorteners to hide their spam/scam content behind other people’s domain names.

I can see how this is a cool project to build and show, but please think very carefully before you want to expose this to the world.

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [October 26, 2024, 9:57am UTC](https://forum.infinityfree.com/t/ssl-certificate-problem-unable-to-get-local-issuer-certificate/100363/4 "2024-10-26T09:57:40Z")

</div>

Closed on October 26, 2024, 9:57am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
