Search Unity

Webplayer SSL https

Discussion in 'Editor & General Support' started by Staples, Apr 18, 2012.

  1. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Is there a https version of the UnityObject.js?

    Without it, it's pretty annoying to get a fully working SSL Enabled site (without partial non-encrypted content). You need to keep a local copy of the UnityObject AND all of the images that the file links to.
     
  2. pgomes

    pgomes

    Joined:
    Mar 13, 2012
    Posts:
    11
    The partial solution I found for this problem was to:
    - Have a local copy of UnityObject.js;
    - Change the way the internal aC variable is initialized. Replacing the following code:


    Code (csharp):
    1.  
    2. ...
    3. var unityObject=function(){
    4.  
    5. var H="Unity Player",
    6. T="application/vnd.unity",
    7. af=window,
    8. aA=document,
    9. r=navigator,
    10. g=false,
    11. aH=[],
    12. N=[],
    13. O=[],
    14. S=null,
    15. o=null,
    16. V=true,
    17. at=true,
    18. aC="http://webplayer.unity3d.com/",
    19. ...
    20.  

    to

    Code (csharp):
    1.  
    2. ...
    3. var unityObject = function () {
    4.  
    5. var aC ="http://webplayer.unity3d.com/";
    6.    
    7. if (document.location.protocol == 'https:')
    8.    aC = aC.replace("http://", "https://ssl-");
    9.  
    10. var H = "Unity Player",
    11. T = "application/vnd.unity",
    12. af = window,
    13. ...
    14.  
    There are two other references to https, but I haven't tried changing those:
    "var aQ = "http://unityanalyticscapture.appspot.com/event?u=" + encodeURIComponent(an) + "&s=" + encodeURIComponent(aN) + "&e=" + encodeURIComponent(aU);"
    "'javascript:window.open("http://unity3d.com/webplayer/");';"

    I'm not that happy about having a non-updated version of UnityObject.js, but at least I don't get annoying warnings.

    (Using Unity 3.5.2f2 and http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js)
     
  3. GarethGY

    GarethGY

    Joined:
    Jan 7, 2013
    Posts:
    5
    I see you've replaced "http://" with "https://ssl-" in a local UnityObject.js file.

    What I find is that just appending "https://ssl-" to the js file hosted by Unity works for me!

    e.g.
    Code (csharp):
    1. <script type="text/javascript" src="https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
     
  4. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    457
    Hi all,

    We have now added the https UnityObject url to the docs, this should ship with the next Unity drop.

    So instead of just seeing the standard UnityObject url in the first paragraph here: http://docs.unity3d.com/Documentation/Manual/WorkingwithUnityObject.html

    We also added the link for the https url just after the standard url.

    The most upto date url to use with Unity is:

    https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js

    It is backwards compatible with all previously released web games using 3.x Unity.

    Thanks,
    Chris
     
  5. CleanCut

    CleanCut

    Joined:
    Aug 19, 2013
    Posts:
    10
    Hi Chris,

    The dynamic javascript switching between http and https works fine for the one link inside the javascript, but there are still other links out in the page to the install/restart button images that are hard-coded to http://webplayer... which I have to manually alter to https://ssl-webplayer... each time that I export a webplayer.

    Can we fix these as well so I don't have to manually tweak the webplayer build?

    I highly encourage you to use scheme-relative urls. They are recommended to be used in this kind of situation.

    A simple explanation:
    1. Use the same domain name for your http and https content (ie have weplayer.unity3d.com serve https on port 443 instead of relegating it to a completely different domain name)
    2. Write your URLs in the form of "//webplayer.unity3d.com/what/ever.png" and then if the browser is currently on an https site, the links will remain https. If the browser is on an http site, the links act as http.

    This would be a much more forward-looking solution that wouldn't require maintaining custom javascript inside the html page. Your SSL certificate is already a wild-card that covers *.unity3d.com, so you wouldn't even need to install a new SSL certificate. This would save you guys work in the future!
     
    Last edited: Dec 26, 2013
  6. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,664
    You can create your own Webplayer Template with ease.
    Under (Win7) C:\Program Files (x86)\Unity\Editor\Data\Resources\WebPlayerTemplates\, make a duplication of the "Default" folder and name it "Default (Https)". Then change the index.html and the thumbnail.png.
     
    Last edited: Dec 26, 2013
  7. CleanCut

    CleanCut

    Joined:
    Aug 19, 2013
    Posts:
    10
    Thanks for the tip!!! I will give that a try. I'm on OS X, but I bet I can find the corresponding location.
     
  8. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    /Applications/Unity/Unity.app/Contents/Resources/WebPlayerTemplates
     
  9. CleanCut

    CleanCut

    Joined:
    Aug 19, 2013
    Posts:
    10
    That makes it easy, thanks! So it looks like I will need to maintain my custom web template(s) in a separate location and copy them in whenever Unity3D has an update...
     
  10. Voulf

    Voulf

    Joined:
    Apr 28, 2015
    Posts:
    3
  11. Voulf

    Voulf

    Joined:
    Apr 28, 2015
    Posts:
    3
    Hey,

    did you remove the error message yesterday from the http lib as well?

    Adrien