We have an app that connects to a MobileFirst Server. Our app connects fine via HTTP, however it will not connect via HTTPS. The App itself is a native iOS app built with Xcode.
We have a self signed certificate on the server. The server is setup to pass the whole certificate keychain back to the client (Root, Intermediate and finally the server certificate) in that order.
All these certificates have been installed on the client iOS device as well, according to these specifications
Connecting via HTTPS results in the following errors/logs on the client & server. This is using Mobile First 6.3 on Liberty Websphere Application Server.
Client:
2015-03-13 09:52:30.133 WFM[80268:291046] [DEBUG] [WL_CONFIG] -[WLConfig init] in WLConfig.m:68 :: {
"application id" = WFM;
"application version" = "1.0";
environment = iOSnative;
host = "xxxxxxxx";
platformVersion = "6.3.0.00.20141127-1357";
port = 9443;
protocol = https;
wlServerContext = "/worklight/";
wlUid = "wY/mbnwKTDDYQUvuQCdSgg==";
}
2015-03-13 09:52:30.421 WFM[80268:291046] [TRACE] [WL_AUTH] -[WLDeviceAuthManager getWLUniqueDeviceId] in WLDeviceAuthManager.m:71 :: returning UUID from the keychain
2015-03-13 09:52:30.435 WFM[80268:291046] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] +[WLAFHTTPClientWrapper requestWithURL:] in WLAFHTTPClientWrapper.m:37 :: Request url is https://xxxx.com:9443/worklight/apps/services/api/WFM/iOSnative/init
2015-03-13 09:52:30.452 WFM[80268:291046] [DEBUG] [WL_REQUEST] -[WLRequest sendRequest:path:withOptions:] in WLRequest.m:119 :: Request timeout is 60.000000
2015-03-13 09:52:30.465 WFM[80268:291046] [DEBUG] [WL_REQUEST] -[WLRequest sendRequest:path:withOptions:] in WLRequest.m:195 :: Sending request (https://xxxxx:9443/worklight/apps/services/api/WFM/iOSnative/init) with headers:
{
"Accept-Language" = en;
"User-Agent" = "WFM/1 (iPhone Simulator; iOS 8.1; Scale/2.00)/WLNativeAPI/6.3.0.00.20141127-1357";
"X-Requested-With" = XMLHttpRequest;
"x-wl-app-version" = "1.0";
"x-wl-clientlog-appname" = WFM;
"x-wl-clientlog-appversion" = "1.0";
"x-wl-clientlog-deviceId" = "F986FBE9-C91C-459A-BCCE-591B6822D267";
"x-wl-clientlog-env" = iOSnative;
"x-wl-clientlog-model" = "x86_64";
"x-wl-clientlog-osversion" = "8.1";
"x-wl-platform-version" = "6.3.0.00.20141127-1357";
}
Post Data: action=test&isAjaxRequest=true
2015-03-13 09:52:30.500 WFM[80268:291046] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:182 :: Starting the request with URL
2015-03-13 09:52:30.513 WFM[80268:291046] [DEBUG] [WL_REQUEST] -[WLRequest sendRequest:path:withOptions:] in WLRequest.m:200 :: waiting for response... (Thread=<NSThread: 0x7fhttps://xxxxx.com:9443/worklight/apps/services/api/WFM/iOSnative/initc1ce110ba0>{number = 1, name = main})
Loading
2015-03-13 09:52:30.769 WFM[80268:291046] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:209 :: Request Failed
2015-03-13 09:52:30.781 WFM[80268:291046] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:210 :: Response Status Code : 0
2015-03-13 09:52:30.794 WFM[80268:291046] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:211 :: Response Error : The operation couldn’t be completed. (NSURLErrorDomain error -1012.)
2015-03-13 09:52:30.838 WFM[80268:291046] [ERROR] [WL_REQUEST] -[WLRequest requestFailed:error:] in WLRequest.m:354 :: Status code='0' error='The operation couldn’t be completed. (NSURLErrorDomain error -1012.)' response='(null)'
2015-03-13 09:52:30.850 WFM[80268:291046] [DEBUG] [WL_REQUEST] -[WLRequest requestFailed:error:] in WLRequest.m:357 :: Response Header: (null)
Response Data: (null)
2015-03-13 09:52:30.860 WFM[80268:291046] [ERROR] [WL_CLIENT] -[WLClient onInitRequestFailure:userInfo:] in WLClient.m:1030 :: onInitRequestFailure
AD WL failed
The operation couldn’t be completed. (NSURLErrorDomain error -1012.)
C.WLErrorCode
0
Server:
Nothing in the messages.log or console.log files. I enabled tracing: <logging traceSpecification="SSL=all:SSLChannel=all"/> and seeing the following in the trace.log file
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink > init, vc=1088683271 Entry
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink < init Exit
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink > ready, vc=1088683271 Entry
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel > getSSLContextForInboundLink Entry
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 host=* port=9443 endPoint=defaultHttpEndpoint-ssl
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 Querying security service for alias=[defaultSSLConfig]
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.websphere.ssl.JSSEHelper > getProperties Entry
defaultSSLConfig
{com.ibm.ssl.remotePort=9443, com.ibm.ssl.direction=inbound, com.ibm.ssl.remoteHost=*, com.ibm.ssl.endPointName=defaultHttpEndpoint-ssl}
null
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.websphere.ssl.JSSEHelper > getSSLPropertiesOnThread Entry
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.ssl.config.ThreadContext 3 getProperties
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.websphere.ssl.JSSEHelper < getSSLPropertiesOnThread Exit
Thread properties are NULL.
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.ssl.config.SSLConfigManager > getSSLConfig: defaultSSLConfig Entry
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.ssl.config.SSLConfigManager < getSSLConfig Exit
SSLConfig.toString() {
com.ibm.ssl.keyStorePassword=********
com.ibm.ssl.daysBeforeExpireWarning=60
com.ibm.ssl.trustStoreFileBased=true
com.ibm.ssl.keyStoreName=defaultKeyStore
config.displayId=keyStore[defaultKeyStore]
com.ibm.ssl.trustStoreReadOnly=false
com.ibm.ssl.contextProvider=SunJSSE
com.ibm.ssl.keyStoreFileBased=true
com.ibm.ssl.alias=defaultSSLConfig
com.ibm.ssl.keyManager=SunX509
com.ibm.ssl.keyStore=C:/Program Files/IBM/WebSphere/Liberty/usr/servers/WorklightServer/resources/security/key.jks
com.ibm.ssl.trustStoreInitializeAtStartup=true
com.ibm.ssl.keyStoreType=jks
com.ibm.ssl.clientAuthentication=false
com.ibm.ssl.keyStoreInitializeAtStartup=true
config.source=file
alias=defaultSSLConfig
id=defaultKeyStore
service.factoryPid=com.ibm.ws.ssl.keystore
config.id=com.ibm.ws.ssl.keystore[defaultKeyStore]
com.ibm.ssl.trustStore=C:/Program Files/IBM/WebSphere/Liberty/usr/servers/WorklightServer/resources/security/key.jks
service.pid=com.ibm.ws.ssl.keystore_133
com.ibm.ssl.tokenEnabled=false
com.ibm.ssl.trustManager=PKIX
com.ibm.ssl.protocol=SSL
com.ibm.ssl.trustStorePassword=********
com.ibm.ssl.trustStoreName=defaultKeyStore
com.ibm.ssl.keyStoreCreateCMSStash=false
config.overrides=true
com.ibm.ssl.trustStoreCreateCMSStash=false
sslRef=defaultSSLConfig
com.ibm.ssl.keyStoreReadOnly=false
com.ibm.ssl.securityLevel=HIGH
com.ibm.ssl.trustStoreType=jks
com.ibm.ssl.validationEnabled=false
}
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.ssl.config.SSLConfigManager > determineIfCSIv2SettingsApply Entry
{com.ibm.ssl.remotePort=9443, com.ibm.ssl.direction=inbound, com.ibm.ssl.remoteHost=*, com.ibm.ssl.endPointName=defaultHttpEndpoint-ssl}
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.ssl.config.SSLConfigManager < determineIfCSIv2SettingsApply (original settings) Exit
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.websphere.ssl.JSSEHelper < getProperties -> direct Exit
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 SSL configuration <null value means non-string>:
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStorePassword = ********
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.daysBeforeExpireWarning = 60
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStoreFileBased = true
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStoreName = defaultKeyStore
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 config.displayId = keyStore[defaultKeyStore]
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStoreReadOnly = false
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.contextProvider = SunJSSE
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStoreFileBased = true
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.alias = defaultSSLConfig
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyManager = SunX509
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStore = C:/Program Files/IBM/WebSphere/Liberty/usr/servers/WorklightServer/resources/security/key.jks
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStoreInitializeAtStartup = true
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStoreType = jks
[13/03/15 10:29:53:921 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.clientAuthentication = false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStoreInitializeAtStartup = true
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 config.source = file
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 alias = defaultSSLConfig
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 id = defaultKeyStore
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 service.factoryPid = com.ibm.ws.ssl.keystore
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 config.id = com.ibm.ws.ssl.keystore[defaultKeyStore]
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStore = C:/Program Files/IBM/WebSphere/Liberty/usr/servers/WorklightServer/resources/security/key.jks
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 service.pid = com.ibm.ws.ssl.keystore_133
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.tokenEnabled = false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustManager = PKIX
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.protocol = SSL
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStorePassword = ********
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStoreName = defaultKeyStore
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStoreCreateCMSStash = false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 config.overrides = true
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStoreCreateCMSStash = false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 sslRef = defaultSSLConfig
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.keyStoreReadOnly = false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.securityLevel = HIGH
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.trustStoreType = jks
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel 3 com.ibm.ssl.validationEnabled = false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 keyStoreType: jks
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 trustStoreType: jks
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.JSSEProviderFactory > getInstance: null Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.JSSEProviderFactory < getInstance: com.ibm.ws.ssl.provider.SunJSSEProvider#8ae8a43 Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 keyStore: C:/Program Files/IBM/WebSphere/Liberty/usr/servers/WorklightServer/resources/security/key.jks
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 keyStoreName: defaultKeyStore
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 keyStorePassword: ********
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 trustStore: C:/Program Files/IBM/WebSphere/Liberty/usr/servers/WorklightServer/resources/security/key.jks
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 trustStoreName: defaultKeyStore
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.SSLConfig 3 trustStorePassword: ********
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.provider.AbstractJSSEProvider > getSSLContext Entry
{com.ibm.ssl.remotePort=9443, com.ibm.ssl.direction=inbound, com.ibm.ssl.remoteHost=*, com.ibm.ssl.endPointName=defaultHttpEndpoint-ssl}
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.config.ThreadContext 3 setOutboundConnectionInfoInternal :null
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.provider.AbstractJSSEProvider 3 outboundConnectionInfo: null
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.provider.AbstractJSSEProvider < getSSLContext -> (from cache) Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLChannel < getSSLContextForInboundLink Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils > getSSLEngine Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLLinkConfig > getEnabledCipherSuites Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.Constants > adjustSupportedCiphersToSecurityLevel Entry
(63) TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 TLS_RSA_WITH_AES_128_CBC_SHA256 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA TLS_RSA_WITH_AES_128_CBC_SHA TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA TLS_ECDH_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA TLS_ECDHE_ECDSA_WITH_RC4_128_SHA TLS_ECDHE_RSA_WITH_RC4_128_SHA SSL_RSA_WITH_RC4_128_SHA TLS_ECDH_ECDSA_WITH_RC4_128_SHA TLS_ECDH_RSA_WITH_RC4_128_SHA SSL_RSA_WITH_RC4_128_MD5 TLS_EMPTY_RENEGOTIATION_INFO_SCSV TLS_DH_anon_WITH_AES_128_CBC_SHA256 TLS_ECDH_anon_WITH_AES_128_CBC_SHA TLS_DH_anon_WITH_AES_128_CBC_SHA TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA SSL_DH_anon_WITH_3DES_EDE_CBC_SHA TLS_ECDH_anon_WITH_RC4_128_SHA SSL_DH_anon_WITH_RC4_128_MD5 SSL_RSA_WITH_DES_CBC_SHA SSL_DHE_RSA_WITH_DES_CBC_SHA SSL_DHE_DSS_WITH_DES_CBC_SHA SSL_DH_anon_WITH_DES_CBC_SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5 SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 SSL_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA TLS_RSA_WITH_NULL_SHA256 TLS_ECDHE_ECDSA_WITH_NULL_SHA TLS_ECDHE_RSA_WITH_NULL_SHA SSL_RSA_WITH_NULL_SHA TLS_ECDH_ECDSA_WITH_NULL_SHA TLS_ECDH_RSA_WITH_NULL_SHA TLS_ECDH_anon_WITH_NULL_SHA SSL_RSA_WITH_NULL_MD5 TLS_KRB5_WITH_3DES_EDE_CBC_SHA TLS_KRB5_WITH_3DES_EDE_CBC_MD5 TLS_KRB5_WITH_RC4_128_SHA TLS_KRB5_WITH_RC4_128_MD5 TLS_KRB5_WITH_DES_CBC_SHA TLS_KRB5_WITH_DES_CBC_MD5 TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 TLS_KRB5_EXPORT_WITH_RC4_40_SHA TLS_KRB5_EXPORT_WITH_RC4_40_MD5
HIGH
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.Constants < adjustSupportedCiphersToSecurityLevel -> (9) TLS_RSA_WITH_AES_128_CBC_SHA256 TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 TLS_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLLinkConfig < getEnabledCipherSuites Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Client auth needed is false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Client auth supported is false
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Calling beginHandshake on engine
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils < getSSLEngine, hc=939063257 Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink 3 SSL engine hc=939063257 associated with vc=1088683271
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink > readyInbound, vc=1088683271 Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink 1 Initial read bytes: 193
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink 1 Before unwrap
netBuf: hc=978838596 pos=0 lim=193 cap=8192
decBuf: hc=1615546952 pos=0 lim=24576 cap=24576
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink 1 After unwrap
netBuf: hc=978838596 pos=193 lim=193 cap=8192
decBuf: hc=1615546952 pos=0 lim=24576 cap=24576
status=OK HSstatus=NEED_TASK consumed=193 produced=0
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils > handleHandshake, engine=939063257 Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 status=OK HSstatus=NEED_TASK
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager > chooseEngineServerAlias Entry
RSA
null
37f8f7d9[SSLEngine[hostname=null port=-1] SSL_NULL_WITH_NULL_NULL]
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager > chooseServerAlias Entry
RSA
null
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.JSSEHelper > getInboundConnectionInfo Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.config.ThreadContext 3 getInboundConnectionInfo
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.websphere.ssl.JSSEHelper < getInboundConnectionInfo Exit
null
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager < chooseServerAlias (from JSSE) Exit
wfm_app_server
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager < chooseEngineServerAlias: wfm_app_server Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager > getPrivateKey Entry
wfm_app_server
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager 3 getX509KeyManager -> sun.security.ssl.SunX509KeyManagerImpl
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager < getPrivateKey -> true Exit
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager > getCertificateChain: wfm_app_server Entry
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager 3 getX509KeyManager -> sun.security.ssl.SunX509KeyManagerImpl
[13/03/15 10:29:53:937 AEDT] 00000073 id= com.ibm.ws.ssl.core.WSX509KeyManager < getCertificateChain Exit
[
[
Version: V3
Subject: OID.0.9.2342.19200300.100.1.3=bradley.dcosta#au1.ibm.com, UID=376595616, CN=xxxxx.com, OU=GBS, O=ibm.com, L=St. Leonards, ST=St. Leonards, C=AU
Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11
Key: Sun RSA public key, 1024 bits
modulus: 0000
public exponent: 0000
Validity: [From: Tue Mar 03 16:00:00 AEDT 2015,
To: Fri Mar 02 15:59:59 AEDT 2018]
Issuer: CN=IBM INTERNAL INTERMEDIATE CA, O=International Business Machines Corporation, C=US
SerialNumber: [ 4fb7]
Certificate Extensions: 6
[1]: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
00000
]
]
[2]: ObjectId: 2.5.29.31 Criticality=false
CRLDistributionPoints [
[DistributionPoint:
[CN=CRL41, CN=IBM INTERNAL INTERMEDIATE CA, O=International Business Machines Corporation, C=US]
, DistributionPoint:
[URIName: http://xxxxxx.com:2001/PKIServ/cacerts/CRL41.crl]
]]
[3]: ObjectId: 2.5.29.32 Criticality=false
CertificatePolicies [
[CertificatePolicyId: [2.5.29.32.0]
[PolicyQualifierInfo: [
qualifierID: 1.3.6.1.5.5.7.2.1
qualifier: 0000: 16 6A 68 74 74 70 3A 2F 2F 77 33 2D 30 33 2E 69 .jhttp://w3-03.i
0010: 62 6D 2E 63 6F 6D 2F 74 72 61 6E 73 66 6F 72 6D bm.com/transform
0020: 2F 73 61 73 2F 61 73 2D 77 65 62 2E 6E 73 66 2F /sas/as-web.nsf/
0030: 43 6F 6E 74 65 6E 74 44 6F 63 73 42 79 54 69 74 ContentDocsByTit
0040: 6C 65 2F 49 6E 66 6F 72 6D 61 74 69 6F 6E 2B 54 le/Information+T
0050: 65 63 68 6E 6F 6C 6F 67 79 2B 53 65 63 75 72 69 echnology+Securi
0060: 74 79 2B 53 74 61 6E 64 61 72 64 73 ty+Standards
], PolicyQualifierInfo: [
qualifierID: 1.3.6.1.5.5.7.2.2
qualifier: 0000: 00000
]] ]
]
[4]: ObjectId: 2.5.29.37 Criticality=false
ExtendedKeyUsages [
serverAuth
]
[5]: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
DigitalSignature
Key_Encipherment
]
[6]: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 19 00 5A 9D FA 45 CF 0E E5 F6 6F 0E A2 7E 12 8E ..Z..E....o.....
0010: FC A5 F5 63 ...c
]
]
]
Algorithm: [SHA256withRSA]
Signature:
0000000
]
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 After task, hsstatus=NEED_WRAP
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 status=OK HSstatus=NEED_WRAP
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 1 before wrap:
encBuf: hc=1861873243 pos=0 lim=24576 cap=24576
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 1 after wrap:
encBuf: hc=1861873243 pos=0 lim=1906 cap=24576
status=OK HSstatus=NEED_UNWRAP consumed=0 produced=1906
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 1 Write bytes: 1906
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Get ready to decrypt data, netBuf: hc=978838596 pos=0 lim=8192 cap=8192
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Nothing was in the buffer
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Do async read
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 Read is not done. Callback will be used.
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils 3 after handshake loop, status=OK HSstatus=NEED_UNWRAP, fromCallback=false, engine=939063257
netBuf: hc=978838596 pos=0 lim=8192 cap=8192
decBuf: hc=1615546952 pos=0 lim=24576 cap=24576
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLUtils < handleHandshake Exit
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink < readyInbound Exit
[13/03/15 10:29:53:984 AEDT] 00000073 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink < ready Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLHandshakeIOCallback 3 Error occured during a read, exception:java.io.IOException: Connection closed: Read failed. Possible end of stream encountered.
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink > error (handshake), vc=1088683271 Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink 3 Caught exception during unwrap, java.io.IOException: Connection closed: Read failed. Possible end of stream encountered.
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink > close, vc=1088683271 Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLWriteServiceContext > close Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLWriteServiceContext < close Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLReadServiceContext > close, vc=1088683271 Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLReadServiceContext < close Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils > shutDownSSLEngine: isServer: true isConnected: true com.ibm.ws.channel.ssl.internal.SSLConnectionLink#5a8fd148 Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils > flushCloseDown Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils 1 before wrap:
buf: hc=1615546952 pos=0 lim=24576 cap=24576
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils 1 after wrap:
buf: hc=1615546952 pos=0 lim=7 cap=24576
status=CLOSED consumed=0 produced=7
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils 1 write bytes: 7
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils < flushCloseDown Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLUtils < shutDownSSLEngine Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink > destroy, vc=1088683271 Entry
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink < destroy Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink < close Exit
[13/03/15 10:29:53:999 AEDT] 00000029 id= com.ibm.ws.channel.ssl.internal.SSLConnectionLink < error (handshake), vc=1088683271 Exit
A couple of suggestions...
All that needs to be installed on the device is the root CA. Nothing else. And it's important that you install this root CA onto the device truststore via email or a secure download link (do not use the browser's cert import).
Ensure that the order in which the server serves the certificate chain, is in the correct order. iOS is much more strict than Android here, and will not trust the server if the order is not correct.
Ensure that the server certificate common name matches the hostname and not an IP. The use of hostname is required.
Try using a diagnostic tool to help debug SSL related issues. For example this will help validate ssl path issues:
openssl s_client -CApath $HOME/CAdir -connect hostname:port
Related
I am trying to determine which students are eligible for promotion by checking how many classes they have attended against a known number of class and if they are add Eligible for promotion in the last value of each of the corresponding rows.
My end goal is to compare each persons total classes and check them against the requirements for each promotion. Each number below is the amount of time in grade at that level before they are eligible for promotion. I haven't tried getting the other belt levels yet. I have just been trying to get White Belt to Yellow Belt working.
Yellow Belt 12 Classes
Orange Belt 48 Classes
Green Belt 64 Classes
Purple Belt 144 Classes
Ikkyu 96 Classes
Nikyu 96 Classes
Sankyu 96 Classes
Shodan 192 Classes
Here is the code....
' RUN QUERY
Access.ExecQuery("SELECT COUNT(StudentID) as TotalClasses, FirstName, LastName FROM Attend GROUP BY FirstName, LastName")
' REPORT & ABORT ON ERRORS
If NoErrors(True) = False Then End
Access.DBDT.Columns.Add("PromotionStatus", GetType(System.String))
For Each row As DataRow In Access.DBDT.Rows
For i = 0 To Access.DBDT.Rows.Count - 1
If (row.Field(Of Integer)(0)) > 12 Then
Access.DBDT.Rows(i)("PromotionStatus") = "Eligible for Yellow Belt"
End If
Next
Next
' FILL DATAGRID
dgvTestDue.DataSource = Access.DBDT
#JayV I tried the code you posted and it worked perfect for anyone with more than 12 classes. I then tried to build on that to process the rest of the time in grade/class requirement and it ignored everything after the first If and did not process any of the ElseIf.
Here is what I tried that didn't work....
If (row.Field(Of Integer)("TotalClasses")) > 12 Then
row("PromotionStatus") = "Eligible for Yellow Belt"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 48 Then
row("PromotionStatus") = "Eligible for Yellow Belt"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 108 Then
row("PromotionStatus") = "Eligible for Green Belt"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 252 Then
row("PromotionStatus") = "Eligible for Purple Belt"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 348 Then
row("PromotionStatus") = "Eligible for Ikkyu"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 444 Then
row("PromotionStatus") = "Eligible for Nikyu"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 540 Then
row("PromotionStatus") = "Eligible for Sankyu"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 636 Then
row("PromotionStatus") = "Eligible for Shodan"
ElseIf (row.Field(Of Integer)("TotalClasses")) > 780 Then
row("PromotionStatus") = "Eligible for Nidan"
End If
and this was the only way I got it to work. Is there any easier/more efficient way and why didn't the ElseIf work?
If (row.Field(Of Integer)("TotalClasses")) > 12 Then
row("PromotionStatus") = "Eligible for Yellow Belt"
End If
If (row.Field(Of Integer)("TotalClasses")) > 48 Then
row("PromotionStatus") = "Eligible for Orange Belt"
End If
If (row.Field(Of Integer)("TotalClasses")) > 108 Then
row("PromotionStatus") = "Eligible for Green Belt"
End If
If (row.Field(Of Integer)("TotalClasses")) > 252 Then
row("PromotionStatus") = "Eligible for Purple Belt"
End If
If (row.Field(Of Integer)("TotalClasses")) > 348 Then
row("PromotionStatus") = "Eligible for Ikkyu"
End If
If (row.Field(Of Integer)("TotalClasses")) > 444 Then
row("PromotionStatus") = "Eligible for Nikyu"
End If
If (row.Field(Of Integer)("TotalClasses")) > 540 Then
row("PromotionStatus") = "Eligible for Sankyu"
End If
If (row.Field(Of Integer)("TotalClasses")) > 636 Then
row("PromotionStatus") = "Eligible for Shodan"
End If
Sorry for the follow question after I marked the original post. I can ask this in a separate question if you want me to.
You are looping through the list of students twice.
Once with
For Each row As DataRow In Access.DBDT.Rows
and a second time with
For i = 0 To Access.DBDT.Rows.Count - 1
and the final assignment of the Eligibility will be based on the last student in the list (Max Harris).
Using this should take care of the problem
For Each row As DataRow In Access.DBDT.Rows
If (row.Field(Of Integer)("TotalClasses")) > 12 Then
row("PromotionStatus") = "Eligible for Yellow Belt"
End If
Next
It's generally better to use Column names rather than numbers as the order may change.
EDIT after supplemental:
When checking groups of numbers you need to check the upper and lower boundaries in each If (or ElseIf) statement.
Example:
Dim totalClasses As Integer = row.Field(Of Integer)("TotalClasses")
If totalClasses > 12 AndAlso totalClasses <= 48 Then
row("PromotionStatus") = "Eligible for Yellow Belt"
ElseIf totalClasses > 48 AndAlso totalClasses <= 108 Then
row("PromotionStatus") = "Eligible for Orange Belt"
ElseIf totalClasses > 108 AndAlso totalClasses <= 252 Then
row("PromotionStatus") = "Eligible for Green Belt"
ElseIf totalClasses > 252 AndAlso totalClasses <= 348 Then
row("PromotionStatus") = "Eligible for Purple Belt"
ElseIf totalClasses > 348 AndAlso totalClasses <= 444 Then
row("PromotionStatus") = "Eligible for Ikkyu"
ElseIf totalClasses > 444 AndAlso totalClasses <= 540 Then
row("PromotionStatus") = "Eligible for Nikyu"
ElseIf totalClasses > 540 AndAlso totalClasses <= 636 Then
row("PromotionStatus") = "Eligible for Sankyu"
ElseIf totalClasses > 636 Then
row("PromotionStatus") = "Eligible for Shodan"
End If
What was happening in your code was that the first If check was passing, therefore the rest of the cases were not checked against. It is a Logic Error in your code, not a syntax error.
Hye,
I have table Client
date idClient nameClient OpenBal open Payable dr cr comPay close
2016-10-5 CL-MK Kashif CL-MK 9000 33134 0 5000 0 0 0
2016-10-5 CL-MK Kashif CL-MK 0 33134 0 6000 0 0 0
2016-10-5 CL-MA Asim CL-MA -8000 33134 0 0 0 0 0
2016-10-5 CL-MA Asim CL-MA 0 33134 0 7000 0 0 0
2016-10-5 CL-MA Asim CL-MA 0 33134 0 0 0 0 0
2016-10-5 CL-MW Waqar CL-MW 4000 33134 0 5000 0 0 0
2016-10-5 CL-MW Waqar CL-MW 0 33134 0 0 0 0 0
2016-10-5 CL-MW Waqar CL-MW 0 33134 0 8000 0 0 0
2016-10-5 CL-MF Fahad CL-MF -7000 33134 0 0 0 0 0
2016-10-5 CL-MF Fahad CL-MF 0 33134 0 0 0 0 0
2016-10-5 CL-MF Fahad CL-MF 0 33134 0 10000 20000 150000 0
2016-10-5 CL-MF Fahad CL-MF 0 33134 0 0 0 0 0
I used this query to sum of all client
SELECT idClient,nameMemb,min(OpenBal)as OpenBal,sum(open) as open,(min(openBal)+sum(open))as able,sum(re)as re ,sum(cr) as cr,sum(comPay)as comPay,(min(openBal)+sum(open)-sum(re)-sum(cr)+sum(comPay))as close from AddClient WHERE strftime ('%m', date) = '10' group by nameMemb
in the result table the close column have 0 and negative velues
I want to get value greater then zero..
I try this
SELECT idClient,nameMemb,min(OpenBal)as OpenBal,sum(open) as open,(min(openBal)+sum(open))as able,sum(re)as re ,sum(cr) as cr,sum(comPay)as comPay,(min(openBal)+sum(open)-sum(re)-sum(cr)+sum(comPay))as close from AddClient WHERE strftime ('%m', date) = '10' and close > 0 group by nameMemb
but this query not give me result.
I believe you need to use a having clause AFTER your group by. Something like:
SELECT
idClient,nameMemb,min(OpenBal)as OpenBal,sum(open) as open,(min(openBal)+sum(open))as able,sum(re)as re ,sum(cr) as cr,sum(comPay)as comPay,(min(openBal)+sum(open)-sum(re)-sum(cr)+sum(comPay))as close
from
AddClient
WHERE
strftime ('%m', date) = '10'
group by
nameMemb
having
close > 0
I have a program that looks at votes entered for candidates and determines the winner by who has the lowest score. Because the user enters their preferences from 1 to 5 with 1 being the favorite and 5 being the least favorite. If there is a draw the candidate with the most 1's win, if this is still a draw then its the candidate with the most 2's. I have a program but want to know if I can simplify it before I continue to repeat the code to check who got the most 2's ect. This is what I have so far.
If candidate1 < candidate2 And candidate1 < candidate3 And candidate1 < candidate4 And candidate1 < candidate5 Then
MsgBox("The winner is" & LblCand1.Text)
ElseIf candidate2 < candidate1 And candidate2 < candidate3 And candidate2 < candidate4 And candidate2 < candidate5 Then
MsgBox("The winner is" & lblCand2.Text)
ElseIf candidate3 < candidate2 And candidate3 < candidate1 And candidate3 < candidate4 And candidate3 < candidate5 Then
MsgBox("The winner is" & lblCand3.Text)
ElseIf candidate4 < candidate2 And candidate4 < candidate3 And candidate4 < candidate1 And candidate4 < candidate5 Then
MsgBox("The winner is" & lblCand4.Text)
ElseIf candidate5 < candidate2 And candidate5 < candidate3 And candidate5 < candidate4 And candidate5 < candidate1 Then
MsgBox("The winner is" & lblCand5.Text)
ElseIf C1V1s > C2V1s And C1V1s > C3V1s And C1V1s > C4V1s And C1V1s > C5V1s Then
MsgBox("The winner is" & LblCand1.Text)
ElseIf C2V1s > C1V1s And C2V1s > C3V1s And C2V1s > C4V1s And C2V1s > C5V1s Then
MsgBox("The winner is" & lblCand2.Text)
ElseIf C3V1s > C1V1s And C3V1s > C2V1s And C3V1s > C4V1s And C3V1s > C5V1s Then
MsgBox("The winner is" & lblCand3.Text)
ElseIf C4V1s > C1V1s And C4V1s > C2V1s And C4V1s > C3V1s And C4V1s > C5V1s Then
MsgBox("The winner is" & lblCand4.Text)
ElseIf C5V1s > C1V1s And C5V1s > C2V1s And C5V1s > C3V1s And C5V1s > C4V1s Then
MsgBox("The winner is" & lblCand5.Text)
End If
I would recommend that you create a class Candidate which contains a score and a name for each candidate:
Class Candidate
Implements IComparable(Of Candidate)
Public Property Score As Integer
Public Property Name As String
Public Function CompareTo(other As Candidate) As Integer Implements IComparable(Of Candidate).CompareTo
If (other.Score > Me.Score) Then
Return -1
ElseIf (other.Score = Me.Score) Then
Return 0
Else
Return 1
End If
End Function
End Class
Then, if you have a collection of your candidate instances, you can do the following:
Dim myCandidates As New List(Of Candidate)
'fill your list with instances somehow...
MsgBox(String.Format("The winner is {0}", myCandidates.Min().Name))
Note that the Candidate class has to implement the IComparable(Of T) interface so the instances know how to compare themselves from the Min() method.
I have a loop from 1 to 20
I want to go through the loop
only from 6 to 14
For i As Integer = 0 To 19
If i > 6 Or i >= 14 Then
Writeline("My Name:")
End If
Next
This code works:
If i > 6 AndAlso i <= 14 Then Writeline "My Name:"
Above code wont work
If i > 6 Or i >= 14 Then Writeline "My Name:"
this is the same thing as
If i > 6 Then Writeline "My Name:"
maybe you should use
If i > 6 AndAlso i <= 14 Then Writeline "My Name:"
(The issues is with your > and your or)
I'm writing a game, and all my code works, however I'm looking for more efficient methods of writing my code.
Is there a more efficient way to write this particular piece of code
Select Case (N)
Case 1
If Player1HandGroup(14).QuantityInteger > 0 Or Player1HandGroup(17).QuantityInteger > 0 Or (Player1HandGroup(16).QuantityInteger > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 2
If Player1HandGroup(14).QuantityInteger2 > 0 Or Player1HandGroup(17).QuantityInteger2 > 0 Or (Player1HandGroup(16).QuantityInteger2 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 3
If Player1HandGroup(14).QuantityInteger3 > 0 Or Player1HandGroup(17).QuantityInteger3 > 0 Or (Player1HandGroup(16).QuantityInteger3 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 4
If Player1HandGroup(14).QuantityInteger4 > 0 Or Player1HandGroup(17).QuantityInteger4 > 0 Or (Player1HandGroup(16).QuantityInteger4 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
Case 5
If Player1HandGroup(14).QuantityInteger5 > 0 Or Player1HandGroup(17).QuantityInteger5 > 0 Or (Player1HandGroup(16).QuantityInteger5 > 0 And (IDbuster = 8 Or IDbuster = 9 Or _
IDbuster = 10 Or IDbuster = 11)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.Cancel Or DodgeBlockDisarmDialog.DialogResult = Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
End Select
The only difference between each case is:
N represents which player is chosen, then with the particular number of N I decide which Quantity integer in my Structure group to look at.
If there were a way to somehow reduce it to just 1 instance and add the "number" on the quantity integer dynamically, I feel it would really free up a lot of my code allthroughout my project.
Not sure what type Player1HandGroup(14) is, but I am mostly positive that it's of the same type as Player1HandGroup(17) and Player1HandGroup(16). So you could have a Sub that takes a parameter of type Function(of YourTypeOfPlayer1HandGroup), and then pass function(x) x.QuantityInteger into it, and so on.
IDbuster = 8 Or IDbuster = 9 Or IDbuster = 10 Or IDbuster = 11
Can be rewritten as:
{8,9,10,11}.Contains(IDbuster)
So your code would turn to something like this:
Select Case N
Case 1: DoProcessingWithProperty(Function(x) x.QuantityInteger)
Case 2: DoProcessingWithProperty(Function(x) x.QuantityInteger2)
Case 3: DoProcessingWithProperty(Function(x) x.QuantityInteger3)
Case 4: DoProcessingWithProperty(Function(x) x.QuantityInteger4)
Case 5: DoProcessingWithProperty(Function(x) x.QuantityInteger5)
End Select
Where
Sub DoProcessingWithProperty(f As Func(Of YourTypeOfPlayer1HandGroup))
If f(Player1HandGroup(14)) > 0 Or f(Player1HandGroup(17)) > 0 Or _
(f(Player1HandGroup(16)) > 0 And {8,9,10,11}.Contains(IDbuster)) Then
DodgeBlockDisarmDialog.ShowDialog()
If DodgeBlockDisarmDialog.DialogResult=Windows.Forms.DialogResult.Cancel Or _
DodgeBlockDisarmDialog.DialogResult=Windows.Forms.DialogResult.OK Then
DodgeBlockDisarmDialog.PlayerTemp = T
End If
End If
End Sub
This is a very generic refactoring (minimum impact), and it may not be the best way to refactor in your current situation, but it certainly makes it more readable.
Your current data structrue doesn't support healthy practices.
If you have N items of the same type in the same class:
Player1HandGroup(14).QuantityInteger
Player1HandGroup(14).QuantityInteger2
Player1HandGroup(14).QuantityInteger3
Player1HandGroup(14).QuantityInteger4
Player1HandGroup(14).QuantityInteger5
You should create a List(Of T) to hold that:
public class HandGroup
Public Property QuantityInteger As List(Of Integer)
...Etc...
End Class
Player1HandGroup(14).QuantityInteger(0)
Player1HandGroup(14).QuantityInteger(1)
Player1HandGroup(14).QuantityInteger(2)
...etc
That way you could do something like:
if Player1HandGroup(14).QuantityInteger(N) ... etc etc etc