https://github.com/jonashackt/spring-boot-rest-clientcertificate/blob/master/src/test/java/de/jonashackt/RestClientCertTestConfiguration.java

 

jonashackt/spring-boot-rest-clientcertificate

Example project showing how to provide a Spring Boot App that serves a secured REST endpoint, that is called with Spring´s RestTemplate configured to use client authentification with a client certi...

github.com

private char[] allPassword = "allpassword".toCharArray();

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception {

        SSLContext sslContext = SSLContextBuilder
                .create()
                .loadKeyMaterial(ResourceUtils.getFile("classpath:keystore.jks"), allPassword, allPassword)
                .loadTrustMaterial(ResourceUtils.getFile("classpath:truststore.jks"), allPassword)
                .build();

        HttpClient client = HttpClients.custom()
                .setSSLContext(sslContext)
                .build();

        return builder
                .requestFactory(new HttpComponentsClientHttpRequestFactory(client))
                .build();
    }

 

키를 입력하지 않고 우회하는 방법은....

@Bean
    public RestTemplate restTemplate()
            throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
        TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
 
        SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom()
                .loadTrustMaterial(null, acceptingTrustStrategy)
                .build();
 
        SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext);
 
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(csf)
                .build();
 
        HttpComponentsClientHttpRequestFactory requestFactory =
                new HttpComponentsClientHttpRequestFactory();
 
        requestFactory.setHttpClient(httpClient);
        RestTemplate restTemplate = new RestTemplate(requestFactory);
        return restTemplate;
    }

 

 

'java > spring' 카테고리의 다른 글

Rest Doc 관련 링크  (0) 2019.06.16
jta atomikos 설정  (0) 2019.03.04
spring boot 백기선님 동영상 강좌 링크  (0) 2018.03.03
springboot 메모  (0) 2017.05.17
rest api 보여 주는 hal-browser  (0) 2017.04.01
Posted by gt1000

2019. 3. 4. 19:51 java/spring

jta atomikos 설정

아 정말 암 걸릴거 같다.

웬만하면 사용하지 말길 강추 드린다.


주구 장창..... 

아래 오류가 난다.

ERROR: the specified log seems to be in use already


메뉴얼에는....

properties.setProperty("com.atomikos.icatch.log_base_name", propertiesConfig.getLogBaseName());

properties.setProperty("com.atomikos.icatch.output_dir", propertiesConfig.getOutputDir());

properties.setProperty("com.atomikos.icatch.log_base_dir", propertiesConfig.getLogBaseDir());


docbase를 사용하면 오류가 나는데...

appbase를 사용하면 오류가 나지 않는다.



나중에 쓰자.



'java > spring' 카테고리의 다른 글

Rest Doc 관련 링크  (0) 2019.06.16
resttemplate ssl 적용  (0) 2019.06.03
spring boot 백기선님 동영상 강좌 링크  (0) 2018.03.03
springboot 메모  (0) 2017.05.17
rest api 보여 주는 hal-browser  (0) 2017.04.01
Posted by gt1000

https://certbot.eff.org/?fbclid=IwAR0Hpr7oTJbGQuy_HNdSNjNl6WJCp3-_UA9NO0vCDP5p3VRbeNXHvT8LI3c

'웹전반(표준)' 카테고리의 다른 글

Spinner  (0) 2018.10.20
chrome visual inspector 엄청 편리함  (0) 2018.10.04
css un minify site  (0) 2018.05.11
Http 요청 헤더  (0) 2015.01.10
크롬 브라우저 확장 툴  (0) 2014.12.23
Posted by gt1000

블로그 이미지
gt1000

태그목록

공지사항

어제
오늘

달력

 « |  » 2025.5
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함