Closed irfanjs closed 3 years ago
Hello @irfanjs : I believe if you get rid of the classpath
keyword in the path to your keystore it should work. classpath
specifies the config to look in the resources folder (or maybe just wherever the applications.properties
file is), so your Spring config tried to find C:\keystore.p12
in the resources folder.
So, if you have something like server.ssl.key-store=classpath:C:\keystore.p12
, try server.ssl.key-store=C:\keystore.p12
instead.
Thanks. will do the change and update . what about Java version. Is my Java version OK ?
The Java version should be fine. The library is generally built and tested with Java version 8 so there's a chance you could run into a problem, but I've used newer versions of Java without issue.
Thanks @Avery-Dunn I removed the classpath and it moved ahead. but now failing with following error :
>
> - @ConditionalOnClass did not find required class 'org.springframework.web.reactive.config.WebFluxConfigurer' (OnClassCondition)
>
> WebMvcAutoConfiguration.ResourceChainCustomizerConfiguration:
> Did not match:
> - @ConditionalOnEnabledResourceChain did not find class org.webjars.WebJarAssetLocator (OnEnabledResourceChainCondition)
>
> WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#beanNameViewResolver:
> Did not match:
> - @ConditionalOnMissingBean (types: org.springframework.web.servlet.view.BeanNameViewResolver; SearchStrategy: all) found beans of type 'org.springframework.web.servlet.view.BeanNameViewResolver' beanNameViewResolver (OnBeanCondition)
>
> WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#localeResolver:
> Did not match:
> - @ConditionalOnProperty (spring.mvc.locale) did not find property 'locale' (OnPropertyCondition)
>
> WebServiceTemplateAutoConfiguration:
> Did not match:
> - @ConditionalOnClass did not find required class 'org.springframework.oxm.Marshaller' (OnClassCondition)
>
> WebServicesAutoConfiguration:
> Did not match:
> - @ConditionalOnClass did not find required class 'org.springframework.ws.transport.http.MessageDispatcherServlet' (OnClassCondition)
>
> WebSocketMessagingAutoConfiguration:
> Did not match:
> - @ConditionalOnClass did not find required class 'org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer' (OnClassCondition)
>
> WebSocketReactiveAutoConfiguration:
> Did not match:
> - @ConditionalOnWebApplication did not find reactive web application classes (OnWebApplicationCondition)
>
> WebSocketServletAutoConfiguration.JettyWebSocketConfiguration:
> Did not match:
> - @ConditionalOnClass did not find required class 'org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer' (OnClassCondition)
>
> WebSocketServletAutoConfiguration.UndertowWebSocketConfiguration:
> Did not match:
> - @ConditionalOnClass did not find required class 'io.undertow.websockets.jsr.Bootstrap' (OnClassCondition)
>
> XADataSourceAutoConfiguration:
> Did not match:
> - @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager' (OnClassCondition)
>
>
> Exclusions:
> -----------
>
> None
>
>
> Unconditional classes:
> ----------------------
>
> org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
>
> org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
>
> org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
>
>
>
> 2021-04-27 06:00:41.592 DEBUG 13204 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : Application failed to start due to an exception
>
> org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException: Connector configured to listen on port 8445 failed to start
> at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.checkConnectorHasStarted(TomcatWebServer.java:228) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.checkThatConnectorsHaveStarted(TomcatWebServer.java:220) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:200) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.9.RELEASE.jar!/:5.1.9.RELEASE]
> at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.8.RELEASE.jar!/:2.1.8.RELEASE]
> at com.microsoft.azure.springsecuritywebapp.SpringSecurityWebAppApplication.main(SpringSecurityWebAppApplication.java:13) ~[classes!/:0.0.1-SNAPSHOT]
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
> at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
> at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[spring-security-web-app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
> at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[spring-security-web-app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
> at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) ~[spring-security-web-app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
> at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) ~[spring-security-web-app-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
>
> 2021-04-27 06:00:41.599 ERROR 13204 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
>
> ***************************
> APPLICATION FAILED TO START
> ***************************
>
> Description:
>
> The Tomcat connector configured to listen on port 8445 failed to start. The port may already be in use or the connector may be misconfigured.
>
> Action:
>
> Verify the connector's configuration, identify and stop any process that's listening on port 8445, or configure this application to listen on another port.
>
> 2021-04-27 06:00:41.600 DEBUG 13204 --- [ main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1dde4cb2, started on Tue Apr 27 06:00:36 IST 2021
> 2021-04-27 06:00:41.602 DEBUG 13204 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
> 2021-04-27 06:00:41.603 INFO 13204 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
Im sure nothing is running on port 8445 . I checked with command
C:\Users>netstat -ano | find "8445"
C:\Users>
please suggest . Thanks
please suggest
That's a pretty generic error message from Tomcat, so it's hard to tell what could be wrong. I would suggest double checking your port configuration in the sample and in Tomcat: the sample uses port 8443 as a default in a few places so if you're using 8445 then make sure that's the only port the sample references, and the same with your Tomcat configuration (the server.xml file mainly).
You could just try using a different port, though using 8445 or any other unused port shouldn't be an issue. Also, I got that generic error from Tomcat when trying to reproduce your original issue, because I removed classpath
from the config but not classpath:
so there was an extra ':' at the start of the keystore's path. Be sure to check for little configure issues like that.
Thanks @Avery-Dunn.
first of all, I am not using 8445 port . I was getting error so I changed the port to 8445. I reverted back the port to 8443. . Now in application.properties
file, I have 8443 port now as default.
Further, I don't find server.xml
file . can you tell me the path ?
Just to be clear, are you saying that you got the error you posted above when using port 8443, and then tried 8445 and still got the same error? If so, then it's likely a configuration issue somewhere. As I said, double check the applications.properties
file to make sure you've put the app id/tenant id/client secret, and the keystore alias/password/type/etc. are all set, there could be some small spelling mistake somewhere.
As for the server.xml
file, that's just one of Tomcat's config files, it's not from this sample code. If you're just running the sample through your IDE then whatever embedded Tomcat stuff your IDE has should be fine (I use IntelliJ and haven't need to change any default Tomcat settings there).
However, if you're trying to deploy it to some separate Tomcat server then you'll need to follow the instructions of the Packaging and deploying to container part of the README.
OK. let me paste the current application.properties file which I am using. please review . this file has all the app id/tenant id/client secret, and the keystore alias/password/type/
logging.level.org.springframework.*=DEBUG
server.address=localhost
server.port=8443
homePage=https://${server.address}:${server.port}
ssoServiceUrl=https://login.microsoftonline.com/common
endSessionEndpoint=https://login.microsoftonline.com/common/oauth2/v2.0/logout
security.oauth2.client.client-id=4ff92d0e-c3ac-442f-98eb-0ba49cdeca73
security.oauth2.client.client-secret=BMFU1NEO5AL-6Dk6fZNz.JArjvj_.Z363T
security.oauth2.client.scope=openid profile
security.oauth2.client.authentication-scheme=header
security.oauth2.client.client-authentication-scheme=form
security.oauth2.issuer=https://login.microsoftonline.com/96ece526-9c7d-48b0-8daf-8b93c90a5d18/v2.0
security.oauth2.client.access-token-uri=${ssoServiceUrl}/oauth2/v2.0/token
security.oauth2.client.user-authorization-uri=${ssoServiceUrl}/oauth2/v2.0/authorize
security.oauth2.resource.user-info-uri=https://graph.microsoft.com/oidc/userinfo
server.servlet.session.cookie.secure=true
server.ssl.key-store="C:\\keystore.p12"
server.ssl.key-store-password=password
server.ssl.key-store-type=PKCS12
server.ssl.key-alias=testCert
server.ssl.key-password=password
further, I am using the code as it is . Haven't changed anything . Just downloaded from github and built. for building , I am using Maven and just run the command mvn clean package
after building , just executing the built jar file from target folder using command : java -jar spring-security-web-app-0.0.1-SNAPSHOT.jar
please suggest . Thanks
Try getting rid of the quotes around the keystore password path, I just tried adding them to my config and got a similar error.
Thanks . It worked. now, I'm providing my credentials after clicking on login button. it is redirecting me to the following page ....
In the app registration authentication section, this is what I have :
Is the configuration correct ? Any suggestion please ? Thanks
please suggest @Avery-Dunn
I'm not sure why you'd be getting a 'no reply address provided' error message, even when I don't put any redirect URLs on that page I get a different error and can't reproduce yours. Did you hit the 'save' button on that authentication section?
One other thing I noticed when trying to reproduce your error is that the redirect URL in the README might have been copied wrong during some changes a while back. Try just using https://localhost:8443/login and no other URLs, the sample is working fine for me when I use that. Also, after saving the new config it may take a few minutes for the Azure side of things to update (it's usually very quick/immediate, but rarely I've seen it take a little longer).
Thanks @Avery-Dunn . it moved ahead. this is what now I am getting . so now admin has to approve the request ? Any way to get rid of this message ?
I haven't seen that specific 'Approval required' screen before, but I'd assume it's something related to the security on your Azure account/tenant. Are you using a personal Azure account, or is your account part of some organization (like a company, school, etc.)?
If your account is part of some organization, then yeah you'd have to get approval from your Azure admin.
If it's a personal account, then you may be able to grant admin consent. In the 'API Permissions' section of the app registration, there should be a 'Grant admin consent' button. Normally that's used for granting tenant-wide consent for certain scopes, but it may solve your problem if you have access to it (it's greyed out for me because I'm not an admin)
Thanks @Avery-Dunn . I am checking with admin. will keep you posted
Closing due to inactivity. If you're still having issues or have any related questions, feel free to re-open or leave comment.
Hi, have followed all the steps (till 5) . getting below error while running the app . it says , it does not find the keystore file in the exception but I checked the file is present and all
application.properties
file is also updatedEnvironment OS : windows 10 Java version : openjdk 11 2018-09-25 OpenJDK Runtime Environment 18.9 (build 11+28) OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
can you please suggest what could be wrong ? please suggest