VMware Cloud Community
jstockall
Contributor
Contributor

WebMKS SDK 2.0 non-minified wmks.js

The documentation for the HTML5 console SDK (WebMKS 2.0) states the SDK should contain wmks.js and wmks.min.js but the download only contains the minified version.

0 Kudos
10 Replies
jessehuvmw
Enthusiast
Enthusiast

wmks.js can downloaded from https://vcenter_ip:9443/vsphere-client/js/wmks.js

Cheers, Jesse Hu
0 Kudos
mjrussell
Contributor
Contributor

This doesn't appear to be true. On vcenter 6.0 (update 2) the wmks.js non-minified source is actually version 1 (can see all the way down the bottom of the file there should be something like:

"WMKS.buildNumber = "3817507", WMKS.version = "2.0.0"

On vcenter 6.5 that path doesn't even exist and the HTML 5 console in the new HTML 5 ui uses a minified version of wmks.

If anyone has the non-minified source could you please post it?

Thanks

0 Kudos
jessehuvmw
Enthusiast
Enthusiast

For vCenter 6.5, use https://vcenter65_ip/vsphere-client/js/wmks.min.js which works for me.

Cheers, Jesse Hu
0 Kudos
jessehuvmw
Enthusiast
Enthusiast

Sample Code:

<html>

<head lang="en">

     <meta charset="UTF-8">

     <title>VM Web Console</title>

     <!-- common js/css lib -->

     <link href="css/wmks-all.css" rel="stylesheet" type="text/css" />

     <link href="css/jquery-ui.css" rel="stylesheet" type="text/css" />

     <script src="lib/jquery-1.8.3.min.js"></script>

     <script src="lib/jquery-ui-1.8.16.min.js"></script>

     <script src="lib/wmks.min.js"></script>

</head>

                          

<body>

     <div>This is a sample of showing vSphere VM Web Console.</div>

     <div id="wmksContainer" style="position:absolute;width:100%;height:100%"></div>

     <script>

     // use webmksTicket authentication

     // https://vc_ip/mob/?moid=vm-12&method=acquireTicket with ticketType 'webmks'

     var url = "wss://esx_ip/ticket/226c1316d5e42300";

     var wmks = WMKS.createWMKS("wmksContainer", {}).register(

                  WMKS.CONST.Events.CONNECTION_STATE_CHANGE,

                  function(event,data){

                    if(data.state == WMKS.CONST.ConnectionState.CONNECTED)

                    {

                       console.log("connection state change : connected");

                    }

                  });

                                                             

     wmks.connect(url);

     </script>

</body>

</html>

Cheers, Jesse Hu
0 Kudos
zhenmie365
Contributor
Contributor

thanks Jessehuvmw. I can access vm WebMKS console according your code.

But I still have a question:

Before I running code to access vm console, I had to install certificate using mmc into the client Os in which I used browser to access VM Html5 console according to this site : http://helpdesk.ssls.com/hc/en-us/articles/204333681-How-to-import-intermediate-and-root-certificate....


But if I have hundreds of client which want to access vm html console, I have to install certificate into each client. It's lots of work!!

Is there any easy way ?

0 Kudos
jessehuvmw
Enthusiast
Enthusiast

Hi zhenmie365,

I have two solution for the WSS certificate issue.

A) install CA certificate on each ESXi host

B) Let the end user's web browser to accept the ESXi host certificate manually. You can write source code like this:

   On the web page you are about to display the VM Console,

  1) Use this javascript to check if the ESXi host certificate is already accepted:

<img src="https://esxi_host_ip/bullet.png" style="display: none;" onerror="alert('Certificate not accepted. Add a 2 seconds timer to reload this img.')" onload="alert('Certificate accepted. Close the popup window created in step 2. Show the VM Web Console.')">

  2) If not accepted, open a popup window to visit https://esxi_host_ip/bullet.png, then the web browser will ask the end user whether to add the certificate into exception. After the end user adds the certificate into exception, the parent window will detect the certificate is accepted and close this popup window.

Cheers, Jesse Hu
0 Kudos
ng34534
Contributor
Contributor

Hi Jesse,,

Hope this messages gets to you, I could use some of your help. I am trying to test this solution and I am struggling.

What I've got so far:

- working of a windows 7 and windows 2012 VM

- downloaded latest VMware HTML Console SDK Release 2.1. extracted content to local directory

- downloaded all the js/css (jquery and jquery.ui) file to a directory.

- create console.html made sure script src is pointing to right location

- used the powershell script to generate ticket and wss url. wss://esxihost/ticket/ticketid

- I insert that new wss url into the console.html file  (same code you provided)

- installed the ESXI certificate on the local machine

When i launch the html file i just get the text and blank page. There is no error messages. Mainly testing in IE 11, seems like chrome and mozilla have Java disabled.

How should i troubleshoot this, Is there particular browser that i should be using or Java version?? Any input would be greatly appreciated...Thanks..

0 Kudos
ng34534
Contributor
Contributor

I was able to make it work. Apparently there was some formatting issue when I copied the html console code.

I am trying generate wss connection using method 1 and 3 from the Github script below and I am not able to connect. Does anyone know if this establishing connection to vCenter is still a viable method?? I am testing this against vsphere 6.0 which says is supported.

    // 1) mksTicket authentication. This is not publicly documented.

    // Get ticket from https://vcenter_ip/mob/?moid=vm-57&method=acquireMksTicket

    //var url = "wss://vcenter_ip:9443/vsphere-client/webconsole/authd?mksTicket=52c10d92-1867-4a0e-4c2e-d97df164a817&host=vcenter_ip&port=902&cfgFile=%2Fvmfs%2Fvolumes%2F56600453-39658cc7-9ec6-002219644073%2FNode1%2FNode1.vmx&sslThumbprint=9F:C5:E9:6C:97:ED:CE:0B:BD:86:9F:5F:E7:AB:1C:E2:CA:46:E2:C2";

    // 2) webmksTicket authentication. This is described on a blog http://vittoriop77.blogspot.it/2016/03/vsphere-6-html-console.html

    // Get ticket from  https://vcenter_ip/mob/?moid=vm-57&method=acquireTicket with ticketType 'webmks'

    //var url = "wss://vm_ip:443/ticket/5705500be7278979";

    // 3) CloneSessionTicket authentication

    // Get ticket from https://vcenter_ip/mob/?moid=SessionManager&method=acquireCloneTicket

    var url = "wss://vcenter_ip/vsphere-client/webconsole/authd?vmId=vm-57&vmName=Node1&serverGuid=197cb8a1-4eb3-45ab-a884-fc570c868e49&host=vcenter_ip:443&sessionTicket=cst-VCT-52adf3a2-7b2e-fb7e-0f12-a1e7d66d0c2c--tp-A1-4A-38-40-F8-91-81-B7-44-C2-65-10-B8-4B-25-AB-8B-36-09-C3";

Showing Web Console of a VM via vSphere HTML Console SDK · GitHub

0 Kudos
hellWork
Enthusiast
Enthusiast

https://vc_ip/mob/?moid=vm-12&method=acquireTicket with ticketType 'webmks',

I can't get this parameter.

The official does not show this parameter.

There is no other way to get it. Thank you very much.

0 Kudos
harpreetbedi
Contributor
Contributor

Hi,

You can get help here: https://gitlab.bingosoft.net/hubj/vmware-webconsole/commit/59af47fa9dc46c6dfa9187f41a602e62e0b18fa8#...

See webconsole.html section.

For console access you need install CA certificate on your esxi host to access the VM console from outside.

Install CA certificate on ESXI.  VMware Knowledge Base

0 Kudos