Siemka,
Chcę sobie przerobić tutorial ze Spring Cloud Config Server (https://www.baeldung.com/spring-cloud-configuration) i mam problem z punktem 7.2, czyli z użyciem zakodowanych haseł.
Mam 2 projekty: config-server i config-client (oba to spring bootowe appki).
config-server wygląda następująco:
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.csrf()
.ignoringAntMatchers("/encrypt/**")
.ignoringAntMatchers("/decrypt/**");
super.configure(http);
}
}
application.properties
:
spring.application.name=config-server
server.port=8888
spring.cloud.config.server.git.uri=***
spring.cloud.config.server.git.clone-on-start=true
spring.security.user.name=root
spring.security.user.password=s3cr3t
bootstrap.properties
:
encrypt.keyStore.location=classpath:/config-server.jks
encrypt.keyStore.password=my-s70r3-s3cr3t
encrypt.keyStore.alias=config-server-key
encrypt.keyStore.secret=my-k34-s3cr3t
(Mam w src/main/resources) ten config.server.jks
, wygenerowany według tych komend pokazanych w artykule w punkcie 7.2.
config-client wygląda następująco:
@RestController
public class ExampleController {
@Value("${user.password}")
private String password;
@GetMapping(
value = "/whoami",
produces = MediaType.TEXT_PLAIN_VALUE)
public String whoami() {
return String.format("Hello! Your password is: %s", password);
}
}
application.properties
mam puste
bootstrap.properties
:
spring.application.name=config-client
server.port=8989
spring.profiles.active=dev
spring.cloud.config.uri=http://localhost:8888
spring.cloud.config.username=root
spring.cloud.config.password=s3cr3t
Na projekcie na Githubie są te pliki propertiesowe, m.in. ten wygenerowany z konsoli config-client-dev.properties
. Jedyna różnica jaką zrobiłem w porównaniu do przykładu z tutoriala to to, że wrzuciłem na Githuba po prostu z przegladarki, poprzez upload plików (nie robiłem git commit
z konsoli).
No więc, na czym w ogóle polega mój problem? Otóż aplikacja serwera wstaje, natomiast aplikacja clienta nie wstaje:
Could not resolve placeholder 'user.password' in value "${user.password}"
W logach servera mam:
o.s.c.c.s.e.CipherEnvironmentEncryptor : Cannot decrypt key: user.password (class java.lang.IllegalStateException: Cannot load keys from store: class path resource [config-server.jks])
W kwestii szyfrowania nie mam dużego doświadczenia, może ktoś wie w czym może leżeć problem?
P.S.
Wołam @Shalom i @ŁF bo wiem że w tej kwestii się znacie
EDIT:
Coś chyba z generowaniem hasła nie halo, bo mam user.password={cipher}
w pliku properties (nic za {cipher}
już nie ma)
EDIT2:
Jak coś to mam na kompie jave 14 OpenJdk. Niby powyżej jdk8 nie powinienem musieć zmieniać java policy, ale z tego linka co tam w artykule podali, to i tak ściagnąłem to i wsadziłem te 2 jary do /lib/security