123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Create and Apply SSL Certificate to DD-WRT Web Interface</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="DD-WRT,Network,Home Networking,PKI,Certificates,SSL,How To,Tutorial">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Create and Apply SSL Certificate to DD-WRT Web Interface">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="revised" content="10/24/2022 10:36:21 AM" />
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Create and Apply SSL Certificate to DD-WRT Web Interface</h1>
- </div>
- <div></div>
- <div id="content">
- <p><em>Note: You may need to enable JFFS2 support under Administration > Management > JFFS2 Support to have a usable /jffs location</em></p>
- <h2>Prerequisites</h2>
- <ul>
- <li class="noCheckbox">A XCA PKI database <a href="https://youtu.be/ezzj3x207lQ" target="_blank">https://youtu.be/ezzj3x207lQ</a></li>
- </ul>
- <h2>Create Your SSL Certificate</h2>
- <ol>
- <li>Launch XCA</li>
- <li>Open the PKI database if it is not already (File > Open DataBase), enter password</li>
- <li>Click on the Certificates tab, right click on your Intermediate CA certificate</li>
- <li>Select New</li>
- <li>On the Source tab, make sure Use this Certificate for signing is selected</li>
- <li>Verify your Intermediate CA certificate is selected from the drop down</li>
- <li>Click the Subject tab</li>
- <li>Complete the Distinguished Name section
- <p>internalName: dd-wrt.i12bretro.local<br />
- countryName: US<br />
- stateOrProvinceName: Virginia<br />
- localityName: Northern<br />
- organizationName: i12bretro<br />
- organizationUnitName: i12bretro Certificate Authority<br />
- commonName: dd-wrt.i12bretro.local</p>
- </li>
- <li>Click the Generate a New Key button</li>
- <li>Enter a name and set the key size to at least 2048</li>
- <li>Click Create</li>
- <li>Click on the Extensions tab</li>
- <li>Select End Entity from the type list</li>
- <li>Click Edit next to Subject Alternative Name</li>
- <li>Add any DNS or IP addresses that the certificate will identify</li>
- <li>Update the validity dates to fit your needs</li>
- <li>Click the Key Usage tab</li>
- <li>Under Key Usage select Digital Signature, Key Encipherment</li>
- <li>Under Extended Key Usage select Web Server and Web Client Authentication</li>
- <li>Click the Netscape tab</li>
- <li>Select SSL Server</li>
- <li>Click OK to create the certificate</li>
- </ol>
- <h2>Exporting Required Files</h2>
- <ol>
- <li>In XCA, click on the Certificates tab</li>
- <li>Right click the SSL certificate > Export > File</li>
- <li>Set the file name to cert.pem verify the export format is PEM (*.crt)</li>
- <li>Click OK</li>
- <li>Click the Private Keys tab</li>
- <li>Right click the private key generated for the SSL certificate > Export > File</li>
- <li>Set the file name to key.pem and verify the export format is PEM private (*.pem)</li>
- <li>Click OK</li>
- </ol>
- <h2>Applying SSL Certificates in DD-WRT</h2>
- <ol>
- <li>Open a web browser and navigate to http://DDWRT_IP</li>
- <li>Authenticate with the DD-WRT login</li>
- <li>Click on the Services tab</li>
- <li>Locate the Secure Shell section</li>
- <li>Select the Enable radio option next to SSHd</li>
- <li>Click Apply Settings</li>
- <li>Click on the Administration tab</li>
- <li>Locate the JFFS2 Support heading</li>
- <li>Check the Enable button next to Internal Flash Storage</li>
- <li>Locate the Web Access heading</li>
- <li>Uncheck HTTP</li>
- <li>Check HTTPS</li>
- <li>Click Apply Settings</li>
- <li>Scroll down and click the Reboot Router</li>
- <li>Wait for DD-WRT to come back up</li>
- <li>Download PuTTY <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html" target="_blank">Download</a></li>
- <li>Connect to DD-WRT via PuTTY</li>
- <li>Execute the following commands to create the working directories
- <div class="codeBlock">cd /jffs<br />
- mkdir etc<br />
- mkdir startup</div>
- </li>
- <li>Download the bash script to apply the SSL certificates <a href="https://gist.githubusercontent.com/i12bretro/240ecec51f63ec8550403be0edd10c98/raw/b4d8862374c0b541b55ab58935ddd14bdab82369/binds_on_mount.sh" target="_blank">Download</a></li>
- <li>Download WinSCP <a href="https://winscp.net/eng/downloads.php" target="_blank">Download</a></li>
- <li>Extract WinSCP and run the executable</li>
- <li>Connect to the DD-WRT server via WinSCP</li>
- <li>Navigate to /jffs/etc</li>
- <li>Copy the created cert.pem and key.pem to /jffs/etc</li>
- <li>Navigate to /jffs/startup</li>
- <li>Copy the downloaded binds_on_mount.sh</li>
- <li>Back in PuTTY, execute the following commands
- <div class="codeBlock">cd /jffs/startup<br />
- # make binds_on_mount.sh executable<br />
- chmod +x binds_on_mount.sh</div>
- </li>
- <li>Test binding the newly created certificates manually
- <div class="codeBlock">./binds_on_mount.sh</div>
- <u><strong>If any errors occur do not proceed to the next section until they are resolved</strong></u></li>
- <li>Open a web browser and navigate to https://DDWRT_IP</li>
- <li>If the certificates were bound successfully the generated certificates should now be served by DD-WRT</li>
- </ol>
- <h2>Automatically Applying SSL Certificates on DD-WRT Startup</h2>
- <ol>
- <li>Open a web browser and navigate to http://DDWRT_IP</li>
- <li>Authenticate with the DD-WRT login</li>
- <li>Click on the Administration tab</li>
- <li>Click on the Commands sub-navigation tab</li>
- <li>Paste the following into the Commands textarea
- <p>cd /jffs/startup && ./binds_on_mount.sh > ./log</p>
- </li>
- <li>Click the Save Startup button</li>
- <li>Click on the Management sub-navigation tab</li>
- <li>Scroll to the bottom and click the Reboot Router button</li>
- <li>Wait for the router to reboot</li>
- <li>Refresh the DD-WRT web interface and the created SSL certificates should be used</li>
- </ol>
- <p>On one of my cheaper routers /jffs was read-only and had 0 bytes available. I followed the same steps as above but used a USB flash drive to store the files. I was able to replace /jffs with /tmp/mnt/USB to complete setting up SSL on the device. Leaving HTTP checked under Administration > Management > Web Access can provide a fallback until https is working reliably. If for some reason https stops working you can re-enable access via http by connecting to the router via SSH and running the following commands:<br />
- nvram set httpd_enable=1<br />
- nvram set http_enable=1</p>
- <p>Special thanks to the DD-WRT forums and alexandrusavin on GitHub for inspiration on getting this working<br />
- <a href="https://gist.github.com/alexandrusavin/69b26846d6593d6f217219b5bd8882c4">https://gist.github.com/alexandrusavin/69b26846d6593d6f217219b5bd8882c4</a></p> </div>
- </div>
- </body>
- </html>
-
|