JWT - generate public and private key (YML example)
@SpringBootApplication public class AuthServerApplication implements CommandLineRunner { public static void main(String[] args) { SpringApplication.run(AuthServerApplication.class, args); } @Override public void run(String... args) throws Exception { KeyPairGenerator keyGenerator = KeyPairGenerator.getInstance("RSA"); keyGenerator.initialize(1024); KeyPair kp = keyGenerator.genKeyPair(); PublicKey publicKey = kp.getPublic(); PrivateKey privateKey = kp.getPrivate(); String encodedPublicKey = Base64.getEncoder().encodeToString(publicKey.getEncoded()); String encodedPrivateKey = Base64.getEncoder().encodeToString(privateKey.getEncoded()); System.out.println(convertToPublicKey(encodedPublicKey)); System.out.println(); System.out.println(convertToPrivateKey(encodedPrivateKey)); } private static String convertToPrivateKey(String key) { StringBuilder result = new StringBuilder(); result.append("-----BEGIN PRIVATE KEY-