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 /
avatar image
0
Question by bitbutter · Feb 12, 2014 at 03:09 PM · wwwhttpsssl

How to validate SSL certificate before sending data via https?

My app sends data to a server with a WWWForm. Before I send the data, I'd like to validate that the destination has a valid SSL certificate to prevent the data getting sent to some other untrusted destination (eg. via rewrite rules).

If i understand correctly the WWW object doesn't automatically handle enforcing SSL certificate validity when dealing with https requests. I'm looking for the simplest possible way enforce this, and to not send the data if no valid certificate is found.

I've looked at some .Net documentation for dealing with this kind of scenario but so far I've found it difficult to understand. Does anyone have (or could anyone write) some example code demonstrating how this can be achieved in the simplest way? (I'm open to using a paid-for asset if this would make things simpler here).

Here's a stripped down version of the (no enforcing) code I have at the moment:

     var form:WWWForm = new WWWForm();
     form.AddField("field1","value1");
     form.AddField("field2","value2");
         
     // TODO: Only send data if valid certificate is found
     var www:WWW = new WWW("https://my.sitewithvalidsslcertificate.com", form);
     // Wait until the download is done
     yield www;
     if(www.error != null){
       Debug.Log(www.error);
     } else {
       // TODO: process www.text here
     }
Comment
Add comment · Show 4
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 shopguy · Mar 14, 2014 at 05:42 AM 0
Share

Where did you get your info about WWW not enforcing SSL certificate validity? I'm looking for the opposite, I'm hoping it doesn't validate because I want to use a self-signed certificate, but I don't just want to test on one or two platforms I have access to, I want to know for sure before I start my project.

avatar image shopguy · Mar 14, 2014 at 05:46 AM 1
Share

http://answers.unity3d.com/questions/445951/using-https-and-ssl.html -- based on your comment here and Benproductions1 answer, and the fact he has over 10k rep here, I guess that might be enough "proof" for me. Sorry can't answer your question. At the very least I think you'll need to use some native .NET classes, and they will likely not be available on most platforms (even less with the free version of Unity).

avatar image shopguy · Mar 14, 2014 at 02:12 PM 0
Share

Just tested on a Windows RT Surface (Windows Store build) and on that platform it does complain if certificate is invalid. Guess I'll have to test in HTTP mode and switch to HTTPS after I purchase a certificate + domain.

avatar image shavais · Jun 01, 2014 at 12:14 AM 0
Share

I read that the trusted certificate store that mono uses (non-windows platforms) doesn't necessarily have anything in it. And my app isn't necessarily going to have or be able to get the necessary permissions to be able to add certs to it. So it seems like any use of https on the part of my unity app is going to be vulnerable to $$anonymous$$IT$$anonymous$$ attacks. So I'm looking now at using http, but using a "payload" post variable, which is an encrypted string with serialized data.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bajana · Nov 18, 2015 at 01:08 PM

Hello has anybody solved this problem with WWW and https?

There is error code in Android:

 11-18 11:28:09.857    7407-7426/? E/Unity﹕ ParseDataTest: data:javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
     (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

And Unity error code:

 arseDataTest: data:SSL: certificate subject name 'localhost' does not match target host name 'test.example.com'

Thank you.

Comment
Add comment · 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

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

21 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 avatar image avatar image avatar image avatar image

Related Questions

SSL Ciphers? How to set reliable https Rest calls? 0 Answers

POST a form over HTTPS with unvalidated SSL Certificate 2 Answers

WWW/WWWForm, does Unity validate SSL certificates? 1 Answer

WWW/WWWForm, does Unity validate SSL certificates over HTTPS? 0 Answers

How to avoid reestablishing an HTTPS request, use Connection: Keep-Alive or reuse WWW object? 2 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