0170.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Create and Apply SSL Certificate to DD-WRT Web Interface</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="DD-WRT,Network,Home Networking,PKI,Certificates,SSL,How To,Tutorial">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Create and Apply SSL Certificate to DD-WRT Web Interface">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="10/24/2022 10:36:21 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Create and Apply SSL Certificate to DD-WRT Web Interface</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <p><em>Note: You may need to enable JFFS2 support under Administration &gt; Management &gt; JFFS2 Support to have a usable /jffs location</em></p>
  26. <h2>Prerequisites</h2>
  27. <ul>
  28. <li class="noCheckbox">A XCA PKI database <a href="https://youtu.be/ezzj3x207lQ" target="_blank">https://youtu.be/ezzj3x207lQ</a></li>
  29. </ul>
  30. <h2>Create Your SSL Certificate</h2>
  31. <ol>
  32. <li>Launch XCA</li>
  33. <li>Open the PKI database if it is not already (File &gt; Open DataBase), enter password</li>
  34. <li>Click on the Certificates tab, right click on your Intermediate CA certificate</li>
  35. <li>Select New</li>
  36. <li>On the Source tab, make sure Use this Certificate for signing is selected</li>
  37. <li>Verify your Intermediate CA certificate is selected from the drop down</li>
  38. <li>Click the Subject tab</li>
  39. <li>Complete the Distinguished Name section
  40. <p>internalName: dd-wrt.i12bretro.local<br />
  41. countryName: US<br />
  42. stateOrProvinceName: Virginia<br />
  43. localityName: Northern<br />
  44. organizationName: i12bretro<br />
  45. organizationUnitName: i12bretro Certificate Authority<br />
  46. commonName: dd-wrt.i12bretro.local</p>
  47. </li>
  48. <li>Click the Generate a New Key button</li>
  49. <li>Enter a name and set the key size to at least 2048</li>
  50. <li>Click Create</li>
  51. <li>Click on the Extensions tab</li>
  52. <li>Select End Entity from the type list</li>
  53. <li>Click Edit next to Subject Alternative Name</li>
  54. <li>Add any DNS or IP addresses that the certificate will identify</li>
  55. <li>Update the validity dates to fit your needs</li>
  56. <li>Click the Key Usage tab</li>
  57. <li>Under Key Usage select Digital Signature, Key Encipherment</li>
  58. <li>Under Extended Key Usage select Web Server and Web Client Authentication</li>
  59. <li>Click the Netscape tab</li>
  60. <li>Select SSL Server</li>
  61. <li>Click OK to create the certificate</li>
  62. </ol>
  63. <h2>Exporting Required Files</h2>
  64. <ol>
  65. <li>In XCA, click on the Certificates tab</li>
  66. <li>Right click the SSL certificate &gt; Export &gt; File</li>
  67. <li>Set the file name to cert.pem verify the export format is PEM (*.crt)</li>
  68. <li>Click OK</li>
  69. <li>Click the Private Keys tab</li>
  70. <li>Right click the private key generated for the SSL certificate &gt; Export &gt; File</li>
  71. <li>Set the file name to key.pem and verify the export format is PEM private (*.pem)</li>
  72. <li>Click OK</li>
  73. </ol>
  74. <h2>Applying SSL Certificates in DD-WRT</h2>
  75. <ol>
  76. <li>Open a web browser and navigate to http://DDWRT_IP</li>
  77. <li>Authenticate with the DD-WRT login</li>
  78. <li>Click on the Services tab</li>
  79. <li>Locate the Secure Shell section</li>
  80. <li>Select the Enable radio option next to SSHd</li>
  81. <li>Click Apply Settings</li>
  82. <li>Click on the Administration tab</li>
  83. <li>Locate the JFFS2 Support heading</li>
  84. <li>Check the Enable button next to Internal Flash Storage</li>
  85. <li>Locate the Web Access heading</li>
  86. <li>Uncheck HTTP</li>
  87. <li>Check HTTPS</li>
  88. <li>Click Apply Settings</li>
  89. <li>Scroll down and click the Reboot Router</li>
  90. <li>Wait for DD-WRT to come back up</li>
  91. <li>Download PuTTY <a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html" target="_blank">Download</a></li>
  92. <li>Connect to DD-WRT via PuTTY</li>
  93. <li>Execute the following commands to create the working directories
  94. <div class="codeBlock">cd /jffs<br />
  95. mkdir etc<br />
  96. mkdir startup</div>
  97. </li>
  98. <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>
  99. <li>Download WinSCP <a href="https://winscp.net/eng/downloads.php" target="_blank">Download</a></li>
  100. <li>Extract WinSCP and run the executable</li>
  101. <li>Connect to the DD-WRT server via WinSCP</li>
  102. <li>Navigate to /jffs/etc</li>
  103. <li>Copy the created cert.pem and key.pem to /jffs/etc</li>
  104. <li>Navigate to /jffs/startup</li>
  105. <li>Copy the downloaded binds_on_mount.sh</li>
  106. <li>Back in PuTTY, execute the following commands
  107. <div class="codeBlock">cd /jffs/startup<br />
  108. # make binds_on_mount.sh executable<br />
  109. chmod +x binds_on_mount.sh</div>
  110. </li>
  111. <li>Test binding the newly created certificates manually
  112. <div class="codeBlock">./binds_on_mount.sh</div>
  113. <u><strong>If any errors occur do not proceed to the next section until they are resolved</strong></u></li>
  114. <li>Open a web browser and navigate to https://DDWRT_IP</li>
  115. <li>If the certificates were bound successfully the generated certificates should now be served by DD-WRT</li>
  116. </ol>
  117. <h2>Automatically Applying SSL Certificates on DD-WRT Startup</h2>
  118. <ol>
  119. <li>Open a web browser and navigate to http://DDWRT_IP</li>
  120. <li>Authenticate with the DD-WRT login</li>
  121. <li>Click on the Administration tab</li>
  122. <li>Click on the Commands sub-navigation tab</li>
  123. <li>Paste the following into the Commands textarea
  124. <p>cd /jffs/startup &amp;&amp; ./binds_on_mount.sh &gt; ./log</p>
  125. </li>
  126. <li>Click the Save Startup button</li>
  127. <li>Click on the Management sub-navigation tab</li>
  128. <li>Scroll to the bottom and click the Reboot Router button</li>
  129. <li>Wait for the router to reboot</li>
  130. <li>Refresh the DD-WRT web interface and the created SSL certificates should be used</li>
  131. </ol>
  132. <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 &gt; Management &gt; 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 />
  133. nvram set httpd_enable=1<br />
  134. nvram set http_enable=1</p>
  135. <p>Special thanks to the DD-WRT forums and alexandrusavin on GitHub for inspiration on getting this working<br />
  136. <a href="https://gist.github.com/alexandrusavin/69b26846d6593d6f217219b5bd8882c4">https://gist.github.com/alexandrusavin/69b26846d6593d6f217219b5bd8882c4</a></p> </div>
  137. </div>
  138. </body>
  139. </html>