Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring keystore bean

In spring.application I've specified keystore name and password. I'd like to sign some data with Signature.sign() from java security, but to do that I'd need Keystore. Is there a way to get Spring managed keystore bean, or do I have to create my own keystore, even when it's already used by spring?

like image 796
Andrii Plotnikov Avatar asked Nov 27 '25 22:11

Andrii Plotnikov


1 Answers

You can just use the

@Autowired
private KeyStore keyStore;

if you've configured it correctly in your XML/Java configuration like so

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:crypt="http://springcryptoutils.com/schema/crypt"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
                       http://springcryptoutils.com/schema/crypt http://springcryptoutils.com/schema/crypt.xsd">

    <crypt:keystore id="keystore"
                location="somePath}"
                password="somePassword"/>
</beans>
like image 142
N4zroth Avatar answered Nov 30 '25 11:11

N4zroth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!