Alert shown in insecure tutorials when invalid certificate
This commit is contained in:
parent
ae25814b7a
commit
bb9880c44a
@ -266,6 +266,8 @@ function updateLayout() {
|
||||
* 3) The token must be consumed in Session.connect() method
|
||||
*/
|
||||
|
||||
var OPENVIDU_SERVER_URL = "https://" + location.hostname + ":4443";
|
||||
|
||||
function getToken(mySessionId) {
|
||||
return createSession(mySessionId).then(sId => createToken(sId));
|
||||
}
|
||||
@ -274,14 +276,24 @@ function createSession(sId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://" + location.hostname + ":4443/api/sessions",
|
||||
url: OPENVIDU_SERVER_URL + "/api/sessions",
|
||||
data: JSON.stringify({ customSessionId: sId }),
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
success: response => resolve(response.id),
|
||||
error: error => error.status === 409 ? resolve(sId) : reject(error)
|
||||
error: (error) => {
|
||||
if (error.status === 409) {
|
||||
resolve(sId);
|
||||
} else {
|
||||
console.warn('No connection to OpenVidu Server. This may be a certificate error at ' + OPENVIDU_SERVER_URL);
|
||||
if (window.confirm('No connection to OpenVidu Server. This may be a certificate error at \"' + OPENVIDU_SERVER_URL + '\"\n\nClick OK to navigate and accept it. ' +
|
||||
'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' + OPENVIDU_SERVER_URL + '"')) {
|
||||
location.assign(OPENVIDU_SERVER_URL + '/accept-certificate');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -290,7 +302,7 @@ function createToken(sId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://" + location.hostname + ":4443/api/tokens",
|
||||
url: OPENVIDU_SERVER_URL + "/api/tokens",
|
||||
data: JSON.stringify({ session: sId }),
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
|
||||
|
||||
@ -53,6 +53,8 @@ window.onbeforeunload = function () {
|
||||
* 3) The token must be consumed in Session.connect() method
|
||||
*/
|
||||
|
||||
var OPENVIDU_SERVER_URL = "https://" + location.hostname + ":4443";
|
||||
|
||||
function getToken(mySessionId) {
|
||||
return createSession(mySessionId).then(sessionId => createToken(sessionId));
|
||||
}
|
||||
@ -61,14 +63,24 @@ function createSession(sessionId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://" + location.hostname + ":4443/api/sessions",
|
||||
url: OPENVIDU_SERVER_URL + "/api/sessions",
|
||||
data: JSON.stringify({ customSessionId: sessionId }),
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
success: response => resolve(response.id),
|
||||
error: error => error.status === 409 ? resolve(sessionId) : reject(error)
|
||||
error: (error) => {
|
||||
if (error.status === 409) {
|
||||
resolve(sessionId);
|
||||
} else {
|
||||
console.warn('No connection to OpenVidu Server. This may be a certificate error at ' + OPENVIDU_SERVER_URL);
|
||||
if (window.confirm('No connection to OpenVidu Server. This may be a certificate error at \"' + OPENVIDU_SERVER_URL + '\"\n\nClick OK to navigate and accept it. ' +
|
||||
'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' + OPENVIDU_SERVER_URL + '"')) {
|
||||
location.assign(OPENVIDU_SERVER_URL + '/accept-certificate');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -77,7 +89,7 @@ function createToken(sessionId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://" + location.hostname + ":4443/api/tokens",
|
||||
url: OPENVIDU_SERVER_URL + "/api/tokens",
|
||||
data: JSON.stringify({ session: sessionId }),
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
|
||||
|
||||
@ -12,6 +12,8 @@ import { OpenVidu, Session, Stream, StreamEvent } from 'openvidu-browser';
|
||||
})
|
||||
export class AppComponent implements OnDestroy {
|
||||
|
||||
OPENVIDU_SERVER_URL = 'https://' + location.hostname + ':4443';
|
||||
|
||||
// OpenVidu objects
|
||||
OV: OpenVidu;
|
||||
session: Session;
|
||||
@ -179,10 +181,19 @@ export class AppComponent implements OnDestroy {
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
};
|
||||
return this.httpClient.post('https://' + location.hostname + ':4443/api/sessions', body, options)
|
||||
return this.httpClient.post(this.OPENVIDU_SERVER_URL + '/api/sessions', body, options)
|
||||
.pipe(
|
||||
catchError(error => {
|
||||
error.status === 409 ? resolve(sessionId) : reject(error);
|
||||
if (error.status === 409) {
|
||||
resolve(sessionId);
|
||||
} else {
|
||||
console.warn('No connection to OpenVidu Server. This may be a certificate error at ' + this.OPENVIDU_SERVER_URL);
|
||||
if (window.confirm('No connection to OpenVidu Server. This may be a certificate error at \"' + this.OPENVIDU_SERVER_URL +
|
||||
'\"\n\nClick OK to navigate and accept it. If no certificate warning is shown, then check that your OpenVidu Server' +
|
||||
'is up and running at "' + this.OPENVIDU_SERVER_URL + '"')) {
|
||||
location.assign(this.OPENVIDU_SERVER_URL + '/accept-certificate');
|
||||
}
|
||||
}
|
||||
return observableThrowError(error);
|
||||
})
|
||||
)
|
||||
@ -203,7 +214,7 @@ export class AppComponent implements OnDestroy {
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
};
|
||||
return this.httpClient.post('https://' + location.hostname + ':4443/api/tokens', body, options)
|
||||
return this.httpClient.post(this.OPENVIDU_SERVER_URL + '/api/tokens', body, options)
|
||||
.pipe(
|
||||
catchError(error => {
|
||||
reject(error);
|
||||
|
||||
@ -186,6 +186,8 @@ function initMainVideo(videoElement, userData) {
|
||||
* 3) The token must be consumed in Session.connect() method
|
||||
*/
|
||||
|
||||
var OPENVIDU_SERVER_URL = "https://" + location.hostname + ":4443";
|
||||
|
||||
function getToken(mySessionId) {
|
||||
return createSession(mySessionId).then(sessionId => createToken(sessionId));
|
||||
}
|
||||
@ -194,14 +196,24 @@ function createSession(sessionId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://" + location.hostname + ":4443/api/sessions",
|
||||
url: OPENVIDU_SERVER_URL + "/api/sessions",
|
||||
data: JSON.stringify({ customSessionId: sessionId }),
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
success: response => resolve(response.id),
|
||||
error: error => error.status === 409 ? resolve(sessionId) : reject(error)
|
||||
error: (error) => {
|
||||
if (error.status === 409) {
|
||||
resolve(sessionId);
|
||||
} else {
|
||||
console.warn('No connection to OpenVidu Server. This may be a certificate error at ' + OPENVIDU_SERVER_URL);
|
||||
if (window.confirm('No connection to OpenVidu Server. This may be a certificate error at \"' + OPENVIDU_SERVER_URL + '\"\n\nClick OK to navigate and accept it. ' +
|
||||
'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' + OPENVIDU_SERVER_URL + '"')) {
|
||||
location.assign(OPENVIDU_SERVER_URL + '/accept-certificate');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -210,7 +222,7 @@ function createToken(sessionId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://" + location.hostname + ":4443/api/tokens",
|
||||
url: OPENVIDU_SERVER_URL + "/api/tokens",
|
||||
data: JSON.stringify({ session: sessionId }),
|
||||
headers: {
|
||||
"Authorization": "Basic " + btoa("OPENVIDUAPP:MY_SECRET"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user