Skip to content

Instantly share code, notes, and snippets.

@smhnaji
Last active July 23, 2024 09:19
Show Gist options
  • Select an option

  • Save smhnaji/cf2a19d158b10f836ab1fb421d113efe to your computer and use it in GitHub Desktop.

Select an option

Save smhnaji/cf2a19d158b10f836ab1fb421d113efe to your computer and use it in GitHub Desktop.
Self Signed SSL file generation in Windows

Generating a self-signed SSL certificate on Windows and deploying it to Active Directory clients and Android devices involves several steps. Below are detailed instructions for each part of the process.

Step 1: Generate a Self-Signed SSL Certificate on Windows

  1. Install OpenSSL:

    • Download the Windows version of OpenSSL from a trusted source (e.g., Shining Light Productions).
    • Install OpenSSL and ensure the installation path is added to your system's PATH environment variable.
  2. Open Command Prompt:

    • Press Win + R, type cmd, and hit Enter.
  3. Navigate to OpenSSL Directory:

    • Change to the OpenSSL directory (where openssl.exe is located). For example:
      cd C:\OpenSSL-Win64\bin
  4. Generate the Private Key and Certificate:

    • Run the following command to create a self-signed certificate:
      openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout C:\path\to\your\server.key -out C:\path\to\your\server.crt
    • Replace C:\path\to\your\ with your desired file path.
    • You will be prompted to enter details for the certificate (country, state, organization, etc.). Fill in as appropriate.
  5. Create a Certificate Chain File (if needed):

    • If you need a chain file, you can create a simple text file that includes the self-signed certificate:
      copy C:\path\to\your\server.crt C:\path\to\your\chain.pem
    • This chain.pem file will serve as your SSLCertificateChainFile in Apache.

Step 2: Install the Certificate on Active Directory Clients (Windows)

  1. Transfer the Certificate:

    • Copy the server.crt file to a shared location accessible by all Active Directory clients.
  2. Install the Certificate:

    • Open the Group Policy Management Console on your server.
    • Create a new Group Policy Object (GPO) or edit an existing one.
    • Navigate to Computer Configuration > Policies > Windows Settings > Security Settings > Public Key Policies > Trusted Root Certification Authorities.
    • Right-click on Trusted Root Certification Authorities and select Import.
    • Follow the wizard to import the server.crt file from the shared location.
    • Link the GPO to the appropriate Organizational Unit (OU) containing the target computers.
  3. Force Group Policy Update:

    • On the client machines, you can run the following command in the command prompt to force an update:
      gpupdate /force

Step 3: Install the Certificate on Android Devices

  1. Transfer the Certificate:

    • Copy the server.crt file to each Android device (via email, USB, or a shared network location).
  2. Install the Certificate:

    • Open the Settings app on the Android device.
    • Navigate to Security > Install from storage (or similar, depending on the version).
    • Select the server.crt file.
    • Follow the prompts to complete the installation. You may need to set a screen lock if one is not already set.

Step 4: Verify the Installation

  • On Windows Clients: Open a browser and navigate to the server using HTTPS. Check for any security warnings.
  • On Android Devices: Open a browser and navigate to the server using HTTPS. Ensure there are no warnings about the certificate.

Important Notes

  • Security Implications: Self-signed certificates are not trusted by default, so users will see warnings unless the certificate is installed as a trusted root.
  • Network Configuration: Ensure that your server is properly configured to use the self-signed certificate in your Apache configuration:
    SSLCertificateFile "C:/path/to/your/server.crt"
    SSLCertificateChainFile "C:/path/to/your/chain.pem"
  • Certificate Renewal: Remember to renew the certificate before it expires (the example above is valid for 365 days).

By following these steps, you can generate a self-signed SSL certificate on Windows and apply it to all Active Directory clients and Android devices connected to your network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment