Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by GabrielS · Sep 20, 2013 at 09:42 AM · httphttpscertificatessl

Manually validating SSL certificates (no WWW involved)

How can i manually verify an SSL certificate retrieved from a server while communicating through HTTPS but with other means than the WWW class? On .Net 3.5 there's the X509Certificate2.Verify() method but taking a look inside the Mono sources this method is marked with the following attribute:

 [MonoTODO("by default this depends on the incomplete X509Chain")]

What is this supposed to mean? Does it mean that certificate validation in Mono using this method is ultimately unreliable? What good alternative can i use?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ArkaneX · Sep 20, 2013 at 11:25 AM

I don't know what you're trying to achieve, but maybe you can do it with ServicePointManager.ServerCertificateValidationCallback. This needs some additional investigation as well, because one of the callback delegate parameters is X509Chain, and basing on the MonoTODO you posted, there might be some problem related to this class.

UPDATE: I took a look at the thread you provided, and I found an older thread by the developer as well. As I understand, UniWeb uses TcpClient, and if it's true, than for SSL communication it probably uses SslStream. When wrapping TcpClient stream into SslStream, it is possible to provide certificate validation callback - the same I mentioned above. If current implementation doesn't throw any error when connecting to a site with invalid certificate, then probably the callback always returns true.

Maybe you can ask author about this directly, and if it works as I believe, then he should allow for injecting the callback or maybe make it virtual. Hard to say exactly without knowing implementation details though.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GabrielS · Sep 20, 2013 at 12:13 PM 0
Share

Well, what i'm trying to achieve is a fundamental concern of HTTPS/SSL: validate the server's certificate so that you can be sure that the server is indeed who it claims to be. I suspect the WWW/WWWForm classes do this automatically, but due to some deficiencies they have i can't use them so i'll have to rely on something else for web requests, which may not have certificate validation built-in.

avatar image ArkaneX · Sep 20, 2013 at 01:11 PM 0
Share

In this case ServerCertificateValidationCallback should be a perfect solution, although in most cases it is used to do the opposite. It allows you to override standard validation procedure, by for example ignore the fact that certificate expired.

Out of curiosity - how are you trying to access the server? If you use WebRequest class, then it should fail automatically if the certificate is invalid.

avatar image ArkaneX · Sep 20, 2013 at 01:13 PM 0
Share

One more question - could you share why you can't use WWW/WWWForm classes?

avatar image GabrielS · Sep 20, 2013 at 01:17 PM 0
Share

I intend to use the UniWeb asset (HttpWebRequest doesn't even work on iOS), which is superior to WWW/WWWForm in terms of HTTP completeness (headers, content types, timeouts etc), but it does not provide built-in SSL certificate validation. Thanks for the suggestion, i'll try the ServerCertificateValidationCallback and see if it works.

avatar image ArkaneX · Sep 20, 2013 at 01:39 PM 0
Share

If this is a custom solution, then I don't know if my advice still apply... Please post some feedback after testing.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unable to send HTTPS request due to CryptographicException 3 Answers

How can I add a certificate to the Mono Trust store? 1 Answer

How to accept self signed certificate 1 Answer

WWW with HTTPS on Android not working 0 Answers

SSL signed by CA validation 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges