On my webpage I've integrated a foscam webcam. It worked like a charm, until I switched my domain from http to https. The problem seems to be that you're not allowed to communicate with a non-https site (foscam can only communicate over http) from the https site. That seems to make perfectly sense if you think about it from a security perspective, but I would like to know if there's a way around it
To integrate the webcam, I use this script:
<script language="JavaScript" type="text/javascript">
function reload()
{
setTimeout('reloadImg("refresh")',10)
};
function reloadImg(id)
{
var obj = document.getElementById(id);
var date = new Date();
obj.src = "http://www.somedomain.com/snapshot.cgi?user=username&pwd=mypw&t=" + Math.floor(date.getTime()/10);
}
@endif
</script>
and
<img src="http://www.somedomain.com/snapshot.cgi?user=username&pwd=mypw&t" name="refresh" id="refresh" onload='reload(this)' onerror='reload(this)'>
That still works (although the console does show errors like
Mixed Content: The page at ' https://www.somedomain.nl/webcam ' was loaded over HTTPS, but requested an insecure image ' http://www.somedomain.nl/snapshot.cgi?user=user&pwd=pass!&t=145244729934 '. This content should also be served over HTTPS.
The real problem that I have is with the buttons to control the webcam. For that I use code like:
$("#left").click(function(){
$.get( "http://www.somedomain.nl/decoder_control.cgi?command=6&user=username&pwd=pass&onestep=1",
function( data ) {});
});
These buttons do not work anymore, and generate the following error in the console:
Mixed Content: The page at ' https://www.somedomain.nl/webcam ' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ' http://www.somedomain.nl/decoder_control.cgi?command=2&user=someuser&pwd=pass!&onestep=1 '. This request has been blocked; the content must be served over HTTPS.send @ jquery.js:8625jQuery.extend.ajax @ jquery.js:8161jQuery.(anonymous function) @ jquery.js:8306(anonymous function) @ webcam:38jQuery.event.dispatch @ jquery.js:4430elemData.handle @ jquery.js:4116
Is there any way around this?
Probably you should change http to https:
$("#left").click(function(){
$.get( "https://www.somedomain.nl/decoder_control.cgi?command=6&user=username&pwd=pass&onestep=1",
function( data ) {});
});
EDIT : link :
The method how to use https visit: Type https://cameraip:https port/ in the browser directly to login the camera.
But this feature requires new firmware:
The new firmware support HTTPS, it improved the security when you login your camera.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.