Thursday, 19 April 2018

dotPeek. Compiler-Generated Code


What if you want to see Compiler-Generatied Code in dotPeek .net decompiler tool to be able analyse compiled code of generators & async/await things or see other optimizations. It's pretty simple you just need to click on the icon in the toolbar, see image

more information can be found here

Wednesday, 18 April 2018

SSL certificate update on sslforfree.com under custom circumstances

What we have:

  • There is legacy site developed with asp.net mvc and only published site is available (no CI, no sources)
  • Old sertificate is expired
  • We don't have access to DNS settings for DNS manual verification
  • According to site manual verification we need place key file inside site folder /.well-known/acme-challenge (validating URL is http://yoursite.com/.well-known/acme-challenge/{hash})
  • Routing module in the asp.net application tries to match your validation URL for further process but fails cause it can't treat that folder as static folder and tries to find and create controller. For success request of this validation rule corresponding folder must be ignored in Routing module, like:
    
    routes.IgnoreRoute(folderPath)
    
    

How we can validate site in that case?

All recipes in the internet doesn't work. So we need a work around. The solution is pretty simple. All you need is just create another fake site for validating:

  • Create another site yoursite.ssl on the same server in IIS mapped to empty physical folder
  • Create corresponding folders and place the key file inside
  • Place web.config file in key file folder
    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <configuration>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
      </system.webServer>
      <system.web>
        <authorization>
          <allow users="*" />
        </authorization>
      </system.web>
    </configuration>
    
    
    
  • In IIS manager add new MimeType on site level with values fileExtension="." and mimeType="text/json" (<mimeMap fileExtension="." mimeType="text/json" />)
  • Setup the same binding like in original site, both HTTP and HTTPS
  • Stop original and start fake site. Validate. Get SSL sertificate. Stop fake site and start original.
  • Validate
  • Get SSL sertificate
  • Stop fake site and start original
  • Update certificate

As a conclusion - sometimes all you need is just to think a little and discover a work around :)