검색

5.2. 웹 서비스 프록시 보안

download PDF

5.2.1. 개요

이 섹션에서는 실제 웹 서비스의 프록시 역할을 하는 Camel CXF 엔드포인트에서 SSL/TLS 보안을 활성화하는 방법을 설명합니다. 이미 X.509 인증서를 사용할 수 있다고 가정하면 필요한 모든 것은 Spring 구성 파일에 구성 데이터 블록을 추가하는 것입니다(구성 데이터가 httpj:engine-factory 요소에 포함됨). 여기에는 약간의 미묘한 측면만 있습니다. 그러나 Camel CXF 엔드포인트가 SSL/TLS 구성 세부 정보와 어떻게 연관되는지 이해해야 합니다.

5.2.2. 암시적 구성

WS 끝점은 Spring에서 끝점을 생성한 다음 해당 Cryostat 컨테이너에서 SSL/TLS 속성을 구성하여 구성할 수 있습니다. 그러나 다음과 같은 이유로 구성이 다소 혼란스러울 수 있습니다. 그러나 다음과 같은 이유로 (Suppj :engine-factory 요소에 의해 구성된 컨테이너) 는 포함된 WS 끝점을 명시적으로 참조하지 않으며 WS 끝점은 다른 컨테이너를 명시적으로 참조하지 않습니다. WS Endpoint Implicitly Configured by httpj:engine-factory 에 설명된 대로 동일한 TCP 포트를 사용하도록 구성되어 있으므로 컨테이너 컨테이너와 포함된 끝점 간의 연결이 암시적으로 설정됩니다.

WS Endpoint Implicitly Configured by httpj:engine-factory

Element

Camel cxf 03

웹 서비스 엔드포인트와 httpj:engine-factory 요소 간의 연결은 다음과 같이 설정됩니다.

  1. Spring 컨테이너는 httpj:engine-factory 요소가 포함된 파일을 로드하고 구문 분석합니다.
  2. httpj:engine-factory 8080이 생성되면 레지스트리에 해당 항목이 생성되어, metrics에 대한 참조를 저장합니다. httpj:engine-factory Cryostat는 지정된 TCP 포트에서 수신 대기하는 container를 초기화하는 데도 사용됩니다.
  3. WS 끝점이 생성되면 레지스트리를 검사하여 엔드포인트 주소 URL에서 TCP 포트와 동일한 TCP 포트가 있는 httpj:engine-factory 8080을 찾을 수 있는지 확인합니다.
  4. 빈 중 하나가 끝점의 TCP 포트와 일치하면 WS 엔드포인트가 해당 Cryostat 컨테이너에 자체적으로 설치됩니다. Cryostatty 컨테이너에 SSL/TLS가 활성화된 경우 WS 엔드포인트는 이러한 보안 설정을 공유합니다.

5.2.3. SSL/TLS 보안을 컨테이너에 추가하는 단계

SSL/TLS 보안을 컨테이너에 추가하여 WS 프록시 끝점을 보호하려면 다음 단계를 수행합니다.

5.2.4. 번들 리소스에 인증서 추가

이 데모에 사용된 인증서는 Apache CXF 3.3.6.fuse-7_11_1-00015-redhat-00002 제품의 샘플에서 가져옵니다. ( InstallDir/extras/ 디렉토리에서 사용 가능) Apache CXF의 독립 실행형 버전을 설치하는 경우 CXFInstallDir/samples/wsdl_first_https/src/main/config 디렉터리에서 샘플 인증서를 찾을 수 있습니다.

CXFInstallDir/samples/wsdl_first_https/src/main/config 디렉터리의 client Keystore.jk s 키 저장소를CamelInstallDir/example-cxf-proxy/src/main/resources/certs 디렉터리에 복사합니다.

5.2.5. POM을 수정하여 리소스 필터링 전환

번들에 리소스로 직접 인증서를 포함하는 것이 가장 편리한 방법입니다. 그러나 Maven 프로젝트에서 인증서를 리소스로 배포할 때 Maven 리소스 필터링을 비활성화하여 바이너리 파일이 손상됩니다.

Maven에서 .jks 파일 필터링을 비활성화하려면 텍스트 편집기를 사용하여 프로젝트 POM 파일인 CamelInstallDir/examples/camel-example-cxf-proxy/pom.xml 을 열고 다음 resources 요소를 빌드 요소의 하위로 추가합니다.

<?xml version="1.0" encoding="UTF-8"?>
...
<project ...>
  ...
  <build>
    <plugins>
      ...
    </plugins>

    <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <excludes> <exclude>/.jks</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>/.jks</include> </includes> </resource> </resources>
  </build>

</project>

5.2.6. CXF 버스 인스턴스화

Spring XML에서 명시적으로 CXF 버스를 인스턴스화해야 합니다(다음 단계에서 httpj:engine-factory 요소에 의해 인스턴스화되는 컨테이너는). src/main/resources/META-INF/spring 디렉토리에서 camel-config.xml 파일을 편집하여 다음과 같이 cxfcore:bus 요소를 요소의 자식으로 추가합니다.

<beans ... >
    ...
    <cxfcore:bus/>
    ...
</beans>
참고

cxfcore: 네임스페이스 접두사는 이후 단계에서 정의됩니다.

5.2.7. Spring에 httpj:engine-factory 요소 추가

configuration

SSL/TLS 보안을 사용하도록 TCP 포트 9080에서 수신 대기하는 Cryostat 컨테이너를 구성하려면 예 5.2. “httpj:engine-factory Element with SSL/TLS enabled” 에 표시된 대로 src/main/resources/META-INF/spring 디렉터리에서 camel-config.xml 파일을 편집하여 httpj:engine-factory 요소를 추가합니다.

이 예에서 sec:clientAuthentication 요소의 required 속성이 false 로 설정되어 있습니다. 즉, SSL/TLS 핸드셰이크 중에 X.509 인증서를 서버에 제공할 필요가 없습니다 (이러한 인증서가 있는 경우 그렇게 할 수 있음).

예 5.2. httpj:engine-factory Element with SSL/TLS enabled

<beans ... >
    ...
    <httpj:engine-factory bus="cxf">
      <httpj:engine port="${proxy.port}">
        <httpj:tlsServerParameters secureSocketProtocol="TLSv1">
          <sec:keyManagers keyPassword="skpass">
            <sec:keyStore resource="certs/serviceKeystore.jks" password="sspass" type="JKS"/>
          </sec:keyManagers>
          <sec:trustManagers>
            <sec:keyStore resource="certs/serviceKeystore.jks" password="sspass" type="JKS"/>
          </sec:trustManagers>
          <sec:cipherSuitesFilter>
            <sec:include>.*_WITH_3DES_.*</sec:include>
            <sec:include>.*_WITH_DES_.*</sec:include>
            <sec:exclude>.*_WITH_NULL_.*</sec:exclude>
            <sec:exclude>.*_DH_anon_.*</sec:exclude>
          </sec:cipherSuitesFilter>
          <sec:clientAuthentication want="true" required="false"/>
        </httpj:tlsServerParameters>
      </httpj:engine>
    </httpj:engine-factory>

</beans>
중요

5.2.8. cxfcore:, sec: 및 httpj: 접두사를 정의합니다.

camel-config.xml 파일의 beans 요소에 다음 강조 표시된 행을 추가하여 cxfcore: bus 요소 정의 및 httpj: engine-factory 요소의 정의에 표시되는 cxfcore: , sec: namespace 접두사를 정의합니다.

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:cxfcore="http://cxf.apache.org/core"
       xmlns:sec="http://cxf.apache.org/configuration/security"
       xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
       http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
       http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
       ">
참고

xsi:schemaLocation 속성에서 http://cxf.apache.org/configuration/security 스키마의 위치와 http://cxf.apache.org/transports/http-jetty/configuration 스키마를 지정해야 합니다. 이는 OSGi 컨테이너에서 자동으로 제공되지 않습니다.

5.2.9. HTTPS를 사용하도록 프록시 주소 URL 수정

Apache Camel 경로 시작 시 프록시 끝점은 camel-config.xml 파일의 cxf:cxfEndpoint 요소에 의해 구성됩니다. 기본적으로 이 프록시 끝점은 HTTP 프로토콜을 사용하도록 구성되어 있습니다. 그러나 대신 보안 HTTPS 프로토콜을 사용하도록 주소 URL을 수정해야 합니다. camel-config.xml 파일에서 다음 조각에 표시된 대로 cxf:cxfEndpoint 요소의 address 속성을 편집하여 http: 접두사를 https: 접두사로 교체합니다.

<beans ...>
    ...
    <cxf:cxfEndpoint id="reportIncident"
                     address="https://localhost:${proxy.port}/camel-example-cxf-proxy/webservices/incident"
                     endpointName="s:ReportIncidentEndpoint"
                     serviceName="s:ReportIncidentEndpointService"
                     wsdlURL="etc/report_incident.wsdl"
                     xmlns:s="http://reportincident.example.camel.apache.org"/>
    ...
</beans>

또한 주소 URL은 TCP 포트 ${proxy.port} (기본적으로 값 9080 )를 사용하도록 구성되어 있습니다. 이 TCP 포트 값은 http:engine-factory 요소로 구성된 컨테이너의 값과 동일하므로 이 엔드포인트가 Cryostat 컨테이너에 배포되도록 합니다. cxf:cxfEndpoint 의 속성은 “자세한 내용은 WSDL 주소 지정” 에 설명된 대로 WSDL 주소 지정 세부 정보를 지정합니다.

serviceName
WSDL 서비스 이름을 지정합니다.
endpointName
WSDL 포트 이름을 지정합니다.
address
프록시 웹 서비스의 주소 URL을 지정합니다.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.