# Loading cesium over https

**URL:** <https://community.cesium.com/t/loading-cesium-over-https/944>\
**Category:** CesiumJS\
**Created:** [January 22, 2014, 3:03pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944 "2014-01-22T15:03:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [January 22, 2014, 3:03pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/1 "2014-01-22T15:03:27Z")

</div>

I’m trying to load our VWF Cesium application over https( over the company network, we’re using websockets, so we had to move to https). Is there a version of the content that can be served out via https?

Link:

[https://virtualworldframework.com/agi/cesium](https://virtualworldframework.com/agi/cesium)

Thanks,

Scott

[blocked] The page at ‘[https://virtualworldframework.com/agi/cesium/00c9659423a6533d/](https://virtualworldframework.com/agi/cesium/00c9659423a6533d/)’ was loaded over HTTPS, but ran insecure content from ‘[http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?key=AkMnCOd4RF1U7D7qgdBz3Fk1aJB3rgCCI\_DO841suDGxqOg0SMICTE8Ivy5HhAf5&jsonp=jsonp847160](http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?key=AkMnCOd4RF1U7D7qgdBz3Fk1aJB3rgCCI_DO841suDGxqOg0SMICTE8Ivy5HhAf5&jsonp=jsonp847160)’: this content should also be loaded over HTTPS.  
[(index):1](https://virtualworldframework.com/agi/cesium/00c9659423a6533d/)

An error occurred in “r”: [cesium.js:715](https://virtualworldframework.com/agi/cesium/00c9659423a6533d/vwf/model/cesium.js)

An error occurred while accessing [http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?key=AkMnCOd4RF1U7D7qgdBz3Fk1aJB3rgCCI\_DO841suDGxqOg0SMICTE8Ivy5HhAf5](http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?key=AkMnCOd4RF1U7D7qgdBz3Fk1aJB3rgCCI_DO841suDGxqOg0SMICTE8Ivy5HhAf5). [cesium.js:715](https://virtualworldframework.com/agi/cesium/00c9659423a6533d/vwf/model/cesium.js)

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2014, 3:26pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/2 "2014-01-22T15:26:22Z")

</div>

Hi Scott,

There’s no out-of-the-box way to do it unfortunately, but it’s easy to do by changing the BingMapsImageryProvider. You just need to replace ‘http’ with ‘https’. Here’s a hacky but working approach:

Change BingMapsImageryProvider.js, around line 128 to look like this (new line in bold):

var metadataUrl = this.\_url + ‘/REST/v1/Imagery/Metadata/’ + this.\_mapStyle.imagerySetName + ‘?key=’ + this.\_key;

**metadataUrl = metadataUrl.replace(‘http:’, ‘https:’);**

var that = this;

And around line 412:

var url = buildImageUrl(this, x, y, level);

**url = url.replace(‘http:’, ‘https:’);**

return ImageryProvider.loadImage(this, url);

I had hoped that just passing in a new URL with ‘https’ to the BingMapsImageryProvider would do the trick. But unfortunately the result of the Bing Maps metadata service still includes http URLs even if accessed via https.

Kevin

---

<div class="post-metadata">

**Author:** ![Scott\_Hunter](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_hunter/32/2006_2.png) [@Scott\_Hunter](https://community.cesium.com/u/Scott_Hunter)\
**Post date:** [January 22, 2014, 3:28pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/3 "2014-01-22T15:28:49Z")

</div>

It looks like Bing Maps supports HTTPS for their imagery metadata service. Try constructing your BingMapsImageryProvider and passing in:

url: ‘[https://dev.virtualearth.net](https://dev.virtualearth.net)’

instead of the default HTTP URL.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2014, 3:31pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/4 "2014-01-22T15:31:40Z")

</div>

Yep, that was the first thing I tried. Sadly the imageryUrl returned in the metadata response is still http.

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [January 22, 2014, 3:46pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/5 "2014-01-22T15:46:28Z")

</div>

What if the code in the first reply added a check for the current protocol prior to swapping from http to https?

This has actually been an issue for months, so we don’t necessarily need an immediate fix. I could even fix it and issue a pull request if that’s better.

Scott

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2014, 3:51pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/6 "2014-01-22T15:51:01Z")

</div>

A robust solution would check for https in the metadata URL (but not add it), and if the metadata URL is https, it would change http to https in the \_imageUrlTemplate inside the metadataSuccess function. If you do this I would definitely appreciate a pull request!

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [January 22, 2014, 3:56pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/7 "2014-01-22T15:56:27Z")

</div>

Do you have a webpage that describes your pull request process? Just create a branch with the fix and submit a PR?

Scott

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2014, 4:01pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/8 "2014-01-22T16:01:10Z")

</div>

That’s right. You can find more information here:

[https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md)

Probably the main thing, other than what you’ve already said, is that we need a signed Contributor’s License Agreement from you or your organization. You can do that just by emailing it to us. Instructions are above. The CLA essentially says that you own your contributions and that we’re allowed to use them.

Thanks for doing this!

Kevin

---

<div class="post-metadata">

**Author:** ![Chris\_Cooper](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/chris_cooper/32/3554_2.png) [@Chris\_Cooper](https://community.cesium.com/u/Chris_Cooper)\
**Post date:** [January 22, 2014, 9:24pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/9 "2014-01-22T21:24:53Z")

</div>

In case it hasn’t been tried, you may be able to do this without code logic by changing hardcoded URLs in Cesium to this form…

//[dev.virtualearth.net](http://dev.virtualearth.net)

as is common practice when using CDNs…

[http://blog.jonathanoliver.com/2010/09/http-and-https-with-google-cdn/](http://blog.jonathanoliver.com/2010/09/http-and-https-with-google-cdn/)

Please let us know how you go.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [January 22, 2014, 11:30pm UTC](https://community.cesium.com/t/loading-cesium-over-https/944/10 "2014-01-22T23:30:54Z")

</div>

Ah, yes, I always forget about that trick. Good idea. We’ll still need the hack to modify the URLs coming back from the Bing Maps metadata service, though, since those have http hardcoded. But rather than changing http to https, we should remove the “http:” entirely.
