創(chuàng)建一個新的密鑰庫: keytool -genkey -alias websocket -keyalg RSA -keystore websocket.keystore -validity 10950
Enter keystore password:
Re-enter new password:
What is your first and last name?[Unknown]: Arun Gupta
What is the name of your organizational unit?[Unknown]: JBoss Middleware
What is the name of your organization?[Unknown]: Red Hat
What is the name of your City or Locality?[Unknown]: San Jose
What is the name of your State or Province?[Unknown]: CA
What is the two-letter country code for this unit?[Unknown]: US
Is CN=Arun Gupta, OU=JBoss Middleware, O=Red Hat, L=San Jose, ST=CA, C=US correct?[no]: yesEnter key password for <websocket>(RETURN if same as keystore password):
Re-enter new password:
new WebSocket("ws://localhost:8080/endpoint-wss/websocket");
將在Chrome開發(fā)者工具中引發(fā)以下異常:
[blocked] The page at 'https://localhost:8443/endpoint-wss/index.jsp' was loaded over HTTPS, but ran insecure content from 'ws://localhost:8080/endpoint-wss/websocket': this content should also be loaded over HTTPS.
Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.