How To Enable SSL In Magento 2: A 9-Step Guide

How To Enable SSL In Magento 2: A 9-Step Guide

Are you wondering how to enable SSL in Magento 2? Enabling SSL requires proper configuration and understanding of different SSL certificate types.

This tutorial covers everything related to SSL implementation in Magento 2. It will explore SSL installation steps, configuration methods, and troubleshooting tips.

Best Magento Hosting now

Key Takeaway

  • SSL certificates encrypt sensitive data and protect customer information during transactions.

  • Magento SSL certificate protects sensitive customer data, enables secure transactions, and boosts SEO rankings.

  • SSL configuration requires both certificate installation and Magento admin panel settings.

  • Regular SSL monitoring prevents security issues and maintains customer trust.

  • Enabling SSL is simple; you can either enable it in the admin panel or follow a programmatic way.

What Is SSL?

SSL (Secure Socket Layer) is a cryptographic protocol that ensures secure communication over a computer network. It encrypts sensitive information exchanged between a user's browser and a web server.

SSL uses encryption algorithms to scramble data in transit. It makes the information unreadable to hackers. This encryption is important for maintaining trust, especially on ecommerce websites.

SSL operates using a combination of public and private keys. The public key encrypts data, while the private key decrypts it. When a user accesses a website secured by SSL, their browser verifies the website’s SSL certificate. This certificate confirms the website's authenticity and ensures the server’s identity matches the domain.

A secure socket layer also contributes to better SEO rankings, as search engines prioritize HTTPS websites for their reliability and user safety.

Why Is An SSL Certificate Important for Magento?

1. Protects Sensitive Customer Data

SSL encrypts sensitive data such as credit card details, passwords, and personal information. This encryption ensures secure communication between the browser and server. Hackers cannot access or misuse the transmitted data. SSL protects customer privacy and the reputation of the Magento store.

2. Builds Customer Trust

SSL displays a padlock icon in the browser, signaling a secure connection. Customers feel confident sharing sensitive details on the site. A secure website increases trust, encourages purchases, and builds loyalty. It also enhances the Magento store’s credibility and builds long-term customer relationships.

3. Enables Secure Transactions

With an SSL certificate installed, payment gateways work securely. It ensures all transactions are encrypted and protects sensitive payment details. It also prevents unauthorized access and fraud. With this security, customers feel safe completing payments on the Magento store.

4. Avoids Browser Warnings

Non-secure websites trigger “Not Secure” browser warnings. SSL prevents such alerts and protects your reputation. It ensures your site appears professional and trustworthy. Customers are less likely to leave when they see a secure connection.

5. Enhances Seo Rankings

Search engines prioritize HTTPS websites for better rankings. SSL improves your store’s visibility, attracting more organic traffic. Customers and search engines alike also favor secure websites. The increased trust and traffic boost your Magento store’s success.

How To Enable SSL Certificate In Magento?

1. Log In To The Magento Admin Panel

Enter your Magento 2 admin URL to access the admin panel. Then, use your login credentials to log in securely.

2. Navigate To Stores > Configuration

In the left menu, click Stores. Under the Settings section, select Configuration. It is where you can configure SSL and other settings.

3. Go To General > Web

To Enable SSL Certificate In Magento Go to General > Web

To Enable SSL Certificate In Magento Go to General > Web

In the Configuration page, expand the General section. Click Web to view all settings related to URLs and SSL.

4. Expand The Base URLs (Secure) Section

Expand The Base URLs Secure Section

Scroll to the Base URLs (Secure) section. Expand it to access options for enabling secure URLs on the storefront and admin.

5. Set Use Secure URLs On Storefront To Yes

Set Use Secure URLs On Storefront To Yes

Locate the Use Secure URLs option on the Storefront. Select Yes from the drop-down menu. It enables customers to use Magento 2 SSL certificates using secure URLs.

6. Set Use Secure URLs In Admin To Yes

Find the Use Secure URLs option below in the Admin section. Select Yes to enable SSL for the admin panel. It ensures your admin panel is encrypted.

7. Save The Configuration

Click the Save Config button at the top right. It will apply the changes to enable your SSL certificate for Magento.

8. Clear The Magento Cache

Clear The Magento Cache

Go to System > Cache Management from the left menu. Select all cache types and click Flush Magento Cache. It ensures the changes take effect.

9. Verify Your SSL Is Enabled

Visit your Magento store URL. Check for "HTTPS" in the address bar. It confirms your SSL certificate is enabled and working.

Programmatic Ways to encrypt SSL Certificate on your Magento 2

1. Enable SSL Via Database Query

You can update the database settings to enable SSL for Magento.

Follow the below steps:

  • Log in to your Database: Use a database management tool like phpMyAdmin or a MySQL client.

  • Run the SQL Queries: Execute the following queries to update the secure URL settings:

    UPDATE core_config_data SET value = 1 WHERE path IN ('web/secure/use_in_frontend', 'web/secure/use_in_adminhtml'); UPDATE core_config_data SET value = 'https://your-secure-url.com/' WHERE path = 'web/secure/base_url'; UPDATE core_config_data SET value = 'https://your-secure-url.com/' WHERE path = 'web/unsecure/base_url';

    Replace your-secure-url.com with your actual Magento 2 store's secure URL.

  • Flush Cache: Clear the cache using the command:

    php bin/magento cache:flush

2. Enable SSL Via Custom Script

You can create a custom script to enable SSL in Magento 2.

Follow the below steps:

  • Create a PHP Script: Save the following code as enable-ssl.php in the root directory of your Magento installation:
getObjectManager(); $config = $objectManager->get(\Magento\Framework\App\Config\Storage\WriterInterface::class); $config->save('web/secure/use_in_frontend', 1); $config->save('web/secure/use_in_adminhtml', 1); $config->save('web/secure/base_url', 'https://your-secure-url.com/'); $config->save('web/unsecure/base_url', 'https://your-secure-url.com/'); echo "SSL settings have been enabled.";

Replace your-secure-url.com with your Magento website secure URL.

  • Run the Script: Execute the script in your terminal:

    php enable-ssl.php

  • Clear Cache: Flush the Magento cache:

    php bin/magento cache:flush

How To Test SSL For Magento Configuration After Enabling?

1. Access Your Magento 2 Store In A Browser

Open your Magento 2 store in any browser. Type the store URL and press Enter.

2. Verify HTTPS In The Store URL

Check the URL in the browser's address bar. If it starts with HTTPS, the SSL certificate to protect your store is active. It ensures secure communication for data and transactions.

3. Check The Padlock Icon For SSL Validation

Look for a padlock icon next to the URL in the browser. A closed padlock confirms the SSL certificate is enabled. If the padlock is open or missing, there may be issues with the installation process.

4. Use Online Tools To Verify SSL Certificate

An open-source command-line tool like OpenSSL can confirm SSL validity. Enter your Magento store URL on these sites. These tools check if your SSL certificate in its hosting package is correctly configured. They also validate encryption and detect mixed content errors.

5. Review SSL Settings In The Magento Admin Panel

Log in to the Magento 2 admin panel. Go to Stores > Configuration in the left menu. Under General, click on Web. Expand the Base URLs (Secure) section to check the settings.

6. Ensure Secure URLs In The Base URLs (Secure) Section

In the Base URLs (Secure) section, confirm the URLs use HTTPS. Check the Use Secure URLs on Storefront and Use Secure URLs in Admin options. Both must be set to "Yes" for SSL to work across your store and admin panel.

7. Check Cache Configuration And Clear Cache

Incorrect cache settings can cause SSL issues. Go to System > Cache Management in the admin panel. Verify all cache types are enabled. Clear the Magento 2 cache to apply changes.

8. Inspect The Checkout Page For HTTPS

The checkout page is often the most sensitive. Visit the Magento 2 checkout page and ensure the URL starts with HTTPS. It protects the data and transactions for customers' security.

What Tools Can You Use To Verify Magento SSL Certificates?

1. SSL Checker By Qualys SSL Labs

SSL Checker By Qualys SSL Labs

SSL Checker by Qualys SSL Labs provides a deep analysis of your SSL configuration. It's a great way to protect your site by identifying vulnerabilities.

Features

  • Comprehensive SSL report

  • Certificate chain analysis

  • Protocol support detection

Pricing: Free

2. SSL Check By SSL Shopper

SSL Check By SSL Shopper

SSL Check by SSL Shopper is a user-friendly tool for verifying SSL certificate installation. It's an option for small businesses with limited resources.

Features

  • Certificate expiration reminders

  • Hostname verification

  • Detailed error messages

Pricing: Free

3. SSL Certificate Checker By DigiCert

SSL Certificate Checker By DigiCert

SSL Certificate Checker by DigiCert provides a reliable tool for inspecting SSL certificates. It's essential to ensure your SSL certificate is enabled correctly.

Features

  • Certificate validity and expiration checks

  • Installation diagnostics

  • Support for multiple domains and subdomains

Pricing: Free

4. Why No Padlock?

Why No Padlock?

Why No Padlock helps identify insecure elements on your website. It's helpful in ensuring all content is served securely. Features include:

  • Detection of mixed content

  • Detailed reports on insecure items

  • Scheduled scans for ongoing monitoring

Pricing: Free for basic scans. Paid plans start at $5/month for advanced features.

5. Chrome Developer Tools

Chrome Developer Tools

Chrome's built-in developer tools allow you to inspect SSL certificates directly. It's beneficial for developers setting up Magento 2. Here's how you can check the SSL certificate directly on Chrome

  • Click the Three-Dot icon to the right of your address bar

  • Scroll down to More Tools > Developer Tools.

  • Use the >> to go to the Security tab.

  • Click on "View Certificate."

  • Click on view certificate to get full certificate details.

Features

  • Security panel for certificate details

  • Mixed content detection

  • Real-time security state analysis

Pricing: Free

What Additional Configurations Are Needed After Enabling the SSL?

1. Update Base URLs To Secure URLs

Log in to the Magento 2 admin panel. Navigate to Stores > Configuration > General > Web. Update the Base URLs (Secure) to use HTTPS. It ensures secure URLs across your store.

2. Force HTTPS Redirection

Edit the .htaccess file or server configuration. Add rules to force HTTPS URL redirection. It redirects all HTTP traffic to HTTPS. It ensures users access a secure connection.

3. Update Third-Party Service URLs To HTTPS

Review all third-party service integrations. Update their URLs to HTTPS if needed. It includes payment gateways, analytics tools, and APIs. Secure connections prevent mixed-content warnings.

4. Verify CDN And Caching Settings For SSL

Ensure your Content Delivery Network (CDN) supports SSL. Check whether your hosting service includes SSL in its CDN. Update caching settings to respect HTTPS. It avoids serving unsecure cached files.

5. Update Hardcoded HTTP Links In Themes Or Extensions

Search your theme files for hardcoded HTTP links. Update these links to use HTTPS. Repeat the process for any custom extensions. It eliminates potential mixed-content errors

6. Test Checkout And Payment Gateways For SSL Compatibility

Visit the checkout page to confirm that the SSL certificate is enabled. Ensure payment gateways work securely with HTTPS. This step protects data during payment.

7. Clear Magento Cache And Reindex Data

Go to System > Cache Management. Clear the cache to apply SSL changes. Reindex the store data to ensure smooth performance. It completes the configuration process.

How To Automate SSL Certificate Renewal For My Magento Store?

1. Certificate Automation Tools

Certificate Automation Tools

Implement automated certificate management using tools like Certbot. It will ensure continuous security coverage and eliminate manual renewal tasks.

2. Implementation Steps

Setup Automated Renewal

  • Install Certbot on your server

  • Configure automatic renewal with cron jobs

  • Set up monitoring for certificate status

  • Enable automatic validation checks

Monitoring Configuration

  • Enable certificate status monitoring

  • Configure expiration alerts

  • Set up extended validation checks for the certificate chain

  • Monitor SSL health through automated tools

3. Renewal Schedule

Set certificate renewals to occur between three and six months before expiration. It provides buffer time for addressing any potential issues.

How To Ensure That Third-Party Services Are Using SSL?

1. Check The Service Documentation For HTTPS Support

Review the third-party service documentation. Confirm these services support HTTPS connections. Verify they require SSL certificates for secure communication. It ensures safe data transmission.

2. Verify The API Endpoints Use HTTPS

Inspect API endpoints provided by the service. Ensure they start with HTTPS. It is essential to protect the data shared. Non-HTTPS endpoints should be avoided.

3. Update API Keys And URLs In Magento To HTTPS Versions

Log in to Magento 2 to use the admin panel. Navigate to the service integration settings. Update API keys and URLs to their HTTPS versions. It guarantees encrypted communication.

4. Test Service Connections Using HTTPS

Use the service's testing tools or Postman. Verify connections work securely over HTTPS. It ensures the service integrates with your Magento store to use SSL. Correct errors before going live.

5. Monitor Logs For Non-Secure Requests

Review Magento logs in System > Tools > Logs. Look for any non-secure HTTP requests. Update any links or API calls that don't use one SSL. It prevents mixed-content issues.

6. Contact The Service Provider For SSL Compliance Confirmation

Reach out to the service provider. Confirm they comply with SSL standards. You will learn how to configure SSL for a Magento site. Ensure they help create and manage SSL certificates securely.

What Are Common Issues When Enabling Magento 2 SSL Certificate?

1. Mixed Content Warnings

Mixed content occurs when some resources load over HTTP. These insecure resources bypass HTTPS encryption. Hardcoded HTTP links in themes or modules often cause this. Use browser Developer Tools to identify and fix the issue.

2. Incorrect Base URL Configuration

Magento requires updating Base URLs to use HTTPS. This step is essential after you install Magento or enable SSL. Incorrect URLs lead to broken links and missing resources. Update both secure and unsecure Base URLs under Stores > Configuration > Web.

3. SSL Certificate Installation Errors

SSL installation errors often stem from incomplete certificate files. An installed SSL certificate may not work if improperly configured. Use an open-source Magento command-line tool like DigiCert SSL Checker to validate the certificate. Ensure your hosting supports the certificate required for your type.

4. Expired Or Invalid SSL Certificate

SSL certificates expire after a set validity period. Expired certificates result in security warnings and loss of HTTPS. Invalid certificates occur when they're misconfigured or corrupted. Regularly check and renew certificates as needed.

5. Third-Party Extensions Not Using HTTPS

Some third-party extensions hardcode HTTP links. These links create mixed content issues. Update extensions to the latest versions to fix this. If the issue persists, contact the extension vendor for HTTPS support.

6. Performance Issues Due To Improper Caching

Caching issues can occur after enabling SSL. Old cache files may still serve HTTP content. It slows down site performance. Clear Magento's cache under System > Cache Management to apply changes.

7. Redirect Loops After Enabling HTTPS

Redirect loops make the site inaccessible. They occur due to conflicting .htaccess rules. Verify your server's redirection rules for HTTPS. Test the rules to ensure no conflicts exist.

8. Hardcoded HTTP Links In Themes Or Modules

Themes or modules may contain hardcoded HTTP links. These links don't switch to HTTPS automatically. Manually replace HTTP links in theme and module files. Update your code to use Base URLs dynamically.

FAQs

1. Can I use a free SSL certificate for my Magento 2 store?

Yes, you can use free SSL certificates for the Magento 2 store. However, such certificates offer basic Magento security features that are suitable for small stores.

2. How long does it take to install an SSL certificate in Magento 2?

The installation process takes around 15-30 minutes. It includes generating CSR, validating domain ownership, and configuring server settings.

3. Will enabling SSL affect my existing product URLs?

No, enabling SSL will not change your product URLs. When SSL is properly configured, Magento automatically updates all internal links to use HTTPS.

4. Can I switch back to HTTP if SSL causes issues?

Yes, you can revert to HTTP by changing the secure URL settings in Magento's admin. However, this isn't recommended for security reasons.

5. Do I need separate SSL certificates for development and production environments?

No, you can use self-signed certificates for development. Production environments require trusted CA-issued certificates.

6. How do I handle SSL for multiple store views in Magento 2?

Secure all store views with a wildcard or multi-domain SSL certificate. Configure each store view's base URL with HTTPS.

7. What should I do if my SSL certificate shows as untrusted?

Check if intermediate certificates are properly installed. Verify the certificate chain is complete. Contact your SSL provider for a proper certificate bundle.

CTA

Summary

Learn how to enable SSL in Magento 2 to secure your online store. This tutorial covers essential aspects of SSL implementation, including:

  • Install and enable the SSL certificate from trusted providers for secure transactions.

  • Configure SSL through the Magento admin panel with proper URL settings.

  • Enable HTTPS across your store's frontend and backend sections.

  • Monitor SSL health using specialized tools and browser indicators.

  • Maintain SSL security through regular updates and certificate renewals.

Looking for hassle-free SSL implementation? Choose managed Magento hosting for automatic SSL configuration.

Anjali Dalal
Anjali Dalal
Technical Writer

Anjali is a technical writer with over 6 years of experience in product marketing and Magento. Her expertise includes simplifying complex Magento concepts for diverse audiences and creating SEO-optimized content that drives engagement.


Get the fastest Magento Hosting! Get Started