Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Self Signed Cert Questions

Self Signed Cert Questions

Scheduled Pinned Locked Moved Web Development
helpcsharpsysadminwindows-adminsecurity
22 Posts 3 Posters 35 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jsc42

    Would a site name of localhost or 127.0.0.1 / 127.0.0.0 work?

    Richard DeemingR Offline
    Richard DeemingR Offline
    Richard Deeming
    wrote on last edited by
    #13

    That would only work if your client was running on the server. The localhost name and the loopback address always point to the current computer.


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

    1 Reply Last reply
    0
    • Richard DeemingR Richard Deeming

      A self-signed certificate created via IIS will only work for "localhost". If you want to create a self-signed cert for a different host, you'll need to specify the common name for it. For example, in Powershell:

      New-SelfSignedCertificate -DnsName "your-host-name" -CertStoreLocation "cert:\LocalMachine\My"

      New-SelfSignedCertificate (pki) | Microsoft Docs[^] If you're planning on accessing the API from outside of your own network, you'll want a real cert for a real external hostname. Assuming the DNS resolves correctly, you can probably use Let's Encrypt[^] to get a free cert.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      K Offline
      K Offline
      Kevin Marois
      wrote on last edited by
      #14

      Richard Deeming wrote:

      New-SelfSignedCertificate -DnsName "your-host-name" -CertStoreLocation "cert:\LocalMachine\My"

      Can you clarify the -CertStoreLocation here? I don't understand where the cert was created? Thank you

      If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

      Richard DeemingR 1 Reply Last reply
      0
      • K Kevin Marois

        Richard Deeming wrote:

        New-SelfSignedCertificate -DnsName "your-host-name" -CertStoreLocation "cert:\LocalMachine\My"

        Can you clarify the -CertStoreLocation here? I don't understand where the cert was created? Thank you

        If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #15

        It's created in the "computer account" certificate store, under the "Personal" folder. It won't appear in certutil.msc; you'll need to open up MMC, add the certificates snap-in, and select "computer account".


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        K 1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          It's created in the "computer account" certificate store, under the "Personal" folder. It won't appear in certutil.msc; you'll need to open up MMC, add the certificates snap-in, and select "computer account".


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          K Offline
          K Offline
          Kevin Marois
          wrote on last edited by
          #16

          Richard, thanks for your help so far, however, I'm still stuck on this and could use some more help. Here's what I;ve done so far: 1 - Created a self-signed cert. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgjIjxa4aANDC90v?e=1RlBuD) 2 - The Cert appears in the cert store. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgYhLXfbTynXuPJn?e=kjN7sp) 3 - The cert appears in IIS. [here](https://1drv.ms/u/s!AlkRTpT49yCMmgebyjXbM1cp629-?e=l6PIVs) 4 - Add the API in IIS using the cert. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgXPTh4iuqJFvwC1?e=wPINDg) 5 - Browse the site in IIS. I still get the cert error. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgQ2QlVeta149Zu4?e=eDyG9i) I'm guessing that I'm still missing something.

          If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

          Richard DeemingR 1 Reply Last reply
          0
          • K Kevin Marois

            Richard, thanks for your help so far, however, I'm still stuck on this and could use some more help. Here's what I;ve done so far: 1 - Created a self-signed cert. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgjIjxa4aANDC90v?e=1RlBuD) 2 - The Cert appears in the cert store. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgYhLXfbTynXuPJn?e=kjN7sp) 3 - The cert appears in IIS. [here](https://1drv.ms/u/s!AlkRTpT49yCMmgebyjXbM1cp629-?e=l6PIVs) 4 - Add the API in IIS using the cert. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgXPTh4iuqJFvwC1?e=wPINDg) 5 - Browse the site in IIS. I still get the cert error. [Here](https://1drv.ms/u/s!AlkRTpT49yCMmgQ2QlVeta149Zu4?e=eDyG9i) I'm guessing that I'm still missing something.

            If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #17

            Your OneDrive links all return "Something went wrong" errors for me. What's the text of the error message?


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            K 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              Your OneDrive links all return "Something went wrong" errors for me. What's the text of the error message?


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              K Offline
              K Offline
              Kevin Marois
              wrote on last edited by
              #18

              "There is a problem with this website's security certificate. The security certificate presented by this website was issued for a different website's address The security certificate presented by this website was not issued by a trusted certificate authority"

              If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

              Richard DeemingR 1 Reply Last reply
              0
              • K Kevin Marois

                "There is a problem with this website's security certificate. The security certificate presented by this website was issued for a different website's address The security certificate presented by this website was not issued by a trusted certificate authority"

                If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #19

                Kevin Marois wrote:

                The security certificate presented by this website was not issued by a trusted certificate authority"

                Which is to be expected when you're using a self-signed certificate; it wasn't issued by a trusted certificate authority.

                Kevin Marois wrote:

                The security certificate presented by this website was issued for a different website's address

                That suggests you generated the cert for a different host name than the one you're using in the client. For example, if you generated a cert for "localhost", and try to connect to "my-super-pc-name", you'll get this error.


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                K 1 Reply Last reply
                0
                • Richard DeemingR Richard Deeming

                  Kevin Marois wrote:

                  The security certificate presented by this website was not issued by a trusted certificate authority"

                  Which is to be expected when you're using a self-signed certificate; it wasn't issued by a trusted certificate authority.

                  Kevin Marois wrote:

                  The security certificate presented by this website was issued for a different website's address

                  That suggests you generated the cert for a different host name than the one you're using in the client. For example, if you generated a cert for "localhost", and try to connect to "my-super-pc-name", you'll get this error.


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  K Offline
                  K Offline
                  Kevin Marois
                  wrote on last edited by
                  #20

                  Well, it seems that I can now access the API on my server from my Dev PC using Postman:

                  https://marois_dev_1:8091/api/Person/GetPerson?personId=1

                  This part appears to be resolved. Now, I tried to allow access to the API from OUTSIDE my home network I've opened the port on the firewall and router, but it throws

                  "An error occurred while sending the request. "

                  with 2 inner exceptions

                  Inner Exception 1:
                  WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

                  Inner Exception 2:
                  AuthenticationException: The remote certificate is invalid according to the validation procedure.

                  I'm guessing the self-signed cert won't work for this? [UPDATE] This works, but I'd like to hear your thoughts on all of this [https://stackoverflow.com/questions/703272/could-not-establish-trust-relationship-for-ssl-tls-secure-channel-soap\](https://stackoverflow.com/questions/703272/could-not-establish-trust-relationship-for-ssl-tls-secure-channel-soap)

                  //Trust all certificates
                  System.Net.ServicePointManager.ServerCertificateValidationCallback =
                  ((sender, certificate, chain, sslPolicyErrors) => true);

                  If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                  Richard DeemingR 1 Reply Last reply
                  0
                  • K Kevin Marois

                    Well, it seems that I can now access the API on my server from my Dev PC using Postman:

                    https://marois_dev_1:8091/api/Person/GetPerson?personId=1

                    This part appears to be resolved. Now, I tried to allow access to the API from OUTSIDE my home network I've opened the port on the firewall and router, but it throws

                    "An error occurred while sending the request. "

                    with 2 inner exceptions

                    Inner Exception 1:
                    WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

                    Inner Exception 2:
                    AuthenticationException: The remote certificate is invalid according to the validation procedure.

                    I'm guessing the self-signed cert won't work for this? [UPDATE] This works, but I'd like to hear your thoughts on all of this [https://stackoverflow.com/questions/703272/could-not-establish-trust-relationship-for-ssl-tls-secure-channel-soap\](https://stackoverflow.com/questions/703272/could-not-establish-trust-relationship-for-ssl-tls-secure-channel-soap)

                    //Trust all certificates
                    System.Net.ServicePointManager.ServerCertificateValidationCallback =
                    ((sender, certificate, chain, sslPolicyErrors) => true);

                    If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                    Richard DeemingR Offline
                    Richard DeemingR Offline
                    Richard Deeming
                    wrote on last edited by
                    #21

                    The exception from outside is the same as before: a self-signed certificate is not issued by a trusted CA, and won't be trusted by default. The validation callback you've shown will work, but only by turning off all SSL validation. If someone managed to poison the DNS for your external users, they can easily impersonate your service with any certificate, even if it doesn't match the name you've used. You would do better to examine the parameters passed in, and verify that the certificate matches the one you're expecting. But then you would have to update that callback every time your certificate expired and was replaced. Alternatively, you could try to convince your external users to add your certificate to the "trusted" certificate store. But the simplest option is to use a proper domain name, and get a proper certificate. You don't even have to pay for it - so long as your domain can be resolved publicly, you can use Let's Encrypt[^] to get a free cert.


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                    K 1 Reply Last reply
                    0
                    • Richard DeemingR Richard Deeming

                      The exception from outside is the same as before: a self-signed certificate is not issued by a trusted CA, and won't be trusted by default. The validation callback you've shown will work, but only by turning off all SSL validation. If someone managed to poison the DNS for your external users, they can easily impersonate your service with any certificate, even if it doesn't match the name you've used. You would do better to examine the parameters passed in, and verify that the certificate matches the one you're expecting. But then you would have to update that callback every time your certificate expired and was replaced. Alternatively, you could try to convince your external users to add your certificate to the "trusted" certificate store. But the simplest option is to use a proper domain name, and get a proper certificate. You don't even have to pay for it - so long as your domain can be resolved publicly, you can use Let's Encrypt[^] to get a free cert.


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      K Offline
                      K Offline
                      Kevin Marois
                      wrote on last edited by
                      #22

                      Great. Thank you again

                      If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups