比較バージョン

キー

  • この行は追加されました。
  • この行は削除されました。
  • 書式設定が変更されました。

...

IdPv4のインストール

実習セミナー内に準備されたLinuxサーバにJDK、Tomcat、Shibboleth 実習セミナー内に準備されたLinuxサーバにJDK、Jetty、Shibboleth IdPをインストールする手順となっています。


目次
maxLevel2
minLevel2
stylenone


...

  • OS、DNS、ネットワーク、時刻同期などは設定済みとなっています。(Apache HTTP Server、mod_sslもインストール済み)
  • CentOS7
  • メモリ2GB以上
  • Apache HTTP Server 2.4 と mod_ssl
  • Java 8(OpenJDK)11(OpenJDK)
  • Jetty 9.4Apache Tomcat 7
  • Shibboleth IdP v3v4

また、実習環境ではSELinuxは無効化されているものとして手順を記載しています。下記コマンドでSELinux設定が確認できます。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
$ /usr/sbin/getenforce

 


...

アンカー
seminar-idpInst2
seminar-idpInst2

2. Java

...

11(OpenJDK)をインストールする

...

1. インストール

CentOS 7にはOpenJDKのパッケージが用意されていますので、これをyumにてインストールします。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# yum install java

 

-11-openjdk-headless


...

アンカー
seminar-idpInst3
seminar-idpInst3

3

...

. Jetty 9.4 をインストールする

1. インストール

CentOS 7にはTomcatのパッケージが用意されていますので、これをyumにてインストールします。※自動起動スクリプトは、インストールすると自動的に作成されます。7にはJettyのパッケージがないので、ダウンロードしてインストールします。
実習セミナーでは予めダウンロードした「/root/PKG」内の、jetty-distribution-9.4.*.v????????.tar.gz を使います。
さらに、Shibboleth Projectが配布している各種設定ファイル群(jetty-base)を配置します。
こちらも予め「/root/PKG」内に配置してあるものを使用します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# cd /root/PKG
# yum install tomcat

2. 自動起動の設定

 tar zxv -C /opt -f jetty-distribution-9.4.*.v????????.tar.gz
# ( cd /opt ; ln -s jetty-distribution-9.4.*.v???????? /opt/jetty )
# tar zxv -C /opt -f idp-jetty-base-9.4.?.tar.gz


サービス起動は、”jetty”ユーザに設定

"root"ユーザではなく、Jetty起動用のユーザを使用することを推奨します。
ここでは、一般的な "jetty" ユーザを作成します。(以降、"jetty"ユーザを使用する事を前提として説明します。)以下のコマンドで自動起動設定を有効にします。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

#

systemctl enable tomcat
補足:
以下のコマンドで自動起動設定を無効にすることができます。
# systemctl disable tomcat

3JAVA_OPTSの設定 

以下のように/etc/sysconfig/tomcatを修正します

コード ブロック
languagebash
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
JAVA_OPTS="-server -Xmx1500m -XX:MaxPermSize=256m -XX:+UseG1GC "

4. profileの追加

/etc/profile.d/java-tomcat.sh という新規ファイルを以下の内容で作成します。

groupadd -g 110 jetty
# useradd -u 110 -g jetty -d /opt/jetty-base -s /sbin/nologin -c "Jetty daemon" jetty
useradd: 警告: ホームディレクトリが既に存在します。
skel ディレクトリからのコピーは行いません。

もしくは、
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.

(上の手順でディレクトリ作成済みのため警告が出ますが問題ありません)
以下のコマンドでその他 Jetty 関連の設定ファイルやディレクトリの所有者、パーミッションを設定します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# chown -R root:root /opt/jetty-distribution-9.4.*.v???????? /opt/jetty-base
# chmod -R g-w /opt/jetty-base
# chown jetty:jetty /opt/jetty-base/{logs,tmp}

自動起動スクリプトは、以下のように作成します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# cp -ip /opt/jetty/bin/jetty.sh /etc/init.d/jetty
# cp -ip /opt/jetty/bin/jetty.service /etc/systemd/system/

jetty.serviceについては、コピー後に以下のように[Service]部分を修正します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

[Service]
Type=forking
EnvironmentFile=-/etc/sysconfig/jetty
PIDFile=/opt/jetty-base/tmp/jetty.pid
ExecStart=/etc/init.d/jetty start
ExecStop=/etc/init.d/jetty stop
ExecReload=/etc/init.d/jetty restart
SuccessExitStatus=143
User=jetty
Group=jetty
TimeoutStartSec=150

以下を実行して、修正した内容を反映させます。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# systemctl daemon-reload

以下の内容で/etc/sysconfig/jettyを作成します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

JAVA

コード ブロック
languagebash
# /etc/profile.d/java-tomcat.sh - set Java and Tomcat stuff JAVA_HOME

=/usr/lib/jvm/jre

#export MANPATH=$MANPATH:/usr/java/default/man CATALINA

/bin/java
JETTY_HOME=/

usr/share/tomcat CATALINA

opt/jetty
JETTY_BASE=

$CATALINA_HOME PATH=$JAVA_HOME/bin:$CATALINA_BASE/bin:$CATALINA_HOME/bin:$PATH export PATH JAVA_HOME CATALINA_HOME CATALINA_BASE

追加した環境変数を読み込みます。

パネル

# source /etc/profile

5. Apache の設定

...

/opt/jetty-base
JETTY_RUN=/opt/jetty-base/tmp
JETTY_STATE=/opt/jetty-base/tmp/jetty.state
JETTY_START_TIMEOUT=120


2. 自動起動の設定

以下のコマンドで自動起動設定を有効にします。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# systemctl enable jetty

補足:
以下のコマンドで自動起動設定を無効にすることができます。
# systemctl disable jetty


3. jetty-baseの設定 

以下のように関連する設定ファイルの作成や修正を行います。

/opt/jetty-base/webapps/idp.xml の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
(省略)
ServerName ex-idp-test??.gakunin.nii.ac.jp:80 ← ??は各自割り振られた番番号(0番なら、ex-idp-test00.gakunin.nii.ac.jp 
(省略)

...

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="war"><SystemProperty name="idp.war.path" default="/opt/shibboleth-idp/war/idp.war" /></Set>
<Set name="contextPath"><SystemProperty name="idp.context.path" default="/idp" /></Set>
<Set name="extractWAR">false</Set>
<Set name="copyWebDir">false</Set>
<Set name="copyWebInf">true</Set>
</Configure>

/opt/jetty-base/start.d/idp-backchannel.ini を無効化
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
(省略) 
<VirtualHost _default_:443>
(省略)
ServerName ex-idp-test??.gakunin.nii.ac.jp:443 ← ??は各自割り振られた番号
ProxyPass /idp/ ajp://localhost:8009/idp/    ← 設定を追加
(省略)

6. Tomcat の設定

以下の内容で /etc/httpd/conf.d/virtualhost-localhost80.conf を作成します。

これはShibboleth IdPが提供するreload-metadata.sh等のコマンドを使った操作を可能にするためのものです。

パネル
<VirtualHost localhost:80>
ProxyPass /idp/ ajp://localhost:8009/idp/
</VirtualHost>

以下のように /usr/share/tomcat/conf/server.xml を修正します。

※実習環境では、Connector port="8080" をコメントアウトします。

# mv -i /opt/jetty-base/start.d/idp-backchannel.ini /opt/jetty-base/start.d/idp-backchannel.ini.dist

/opt/jetty-base/start.d/start.ini の作成
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# Any other required Jetty modules...

# Allows setting Java system properties (-Dname=value)
# and JVM flags (-X, -XX) in this file
# NOTE: spawns child Java process
--exec

# Uncomment if IdP is installed somewhere other than /opt/shibboleth-idp
#-Didp.home=/path/to/shibboleth-idp

# Newer garbage collector that reduces memory needed for larger metadata files
-XX:+UseG1GC

# Maximum amount of memory that Jetty may use, at least 1.5G is recommended
# for handling larger (> 25M) metadata files but you will need to test on
# your particular metadata configuration
-Xmx1500m

# Prevent blocking for entropy.
-Djava.security.egd=file:/dev/./urandom

# Set Java tmp location
-Djava.io.tmpdir=tmp

/opt/jetty-base/start.d/idp.ini の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
<!--
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
-->

※Connector port="8009"に以下のように追加してください。

# ---------------------------------------
# Module: idp
# Shibboleth IdP
# ---------------------------------------
--module=idp
--module=http
--module=http-forwarded

## Keystore file path (relative to $jetty.base)
jetty.sslContext.keyStorePath=../credentials/idp-userfacing.p12


(省略)

※末尾に以下を追加

## Connector port to listen on
jetty.ssl.port=443  ※利用されない
jetty.http.host=127.0.0.1
jetty.http.port=8080

/opt/jetty-base/modules/idp.mod の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

[depend]
annotations
deploy
ext
#https
jsp
jstl
plus
resources
server
servlets
#ssl

/opt/jetty-base/etc/tweak-ssl.xml の作成
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
           enableLookups="false" tomcatAuthentication="false" address="127.0.0.1" maxPostSize="100000" />

6. "tomcat"ユーザで起動

 以下のコマンドでその他Tomcat関連の設定ファイルやディレクトリの所有者、パーミッションを設定します。 
 (インストール後の初期設定は、"tomcat"ユーザでTomcatが起動される設定となっています。)

 

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# chown -R tomcat:tomcat /usr/share/tomcat/{temp,logs,work}
# chown tomcat:tomcat /usr/share/tomcat/webapps
# chmod +t /usr/share/tomcat/webapps
# chgrp tomcat /usr/share/tomcat/conf/*.*
# chmod g+r /usr/share/tomcat/conf/*.*
# mkdir -p /usr/share/tomcat/conf/Catalina/localhost

また、Tomcatのpidファイル及び保存されているディレクトリを ls -dl 等で所有者・パーミッションを確認の上、必要なら変更してください。

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_4.dtd">
<Configure id="shibContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="IncludeProtocols">
<Array type="String">
<Item>TLSv1.3</Item>
<Item>TLSv1.2</Item>
</Array>
</Set>
<Set name="ExcludeProtocols">
<Array type="String">
<Item>TLSv1.1</Item>
<Item>TLSv1</Item>
<Item>SSL</Item>
<Item>SSLv2</Item>
<Item>SSLv3</Item>
</Array>
</Set>
<Set name="IncludeCipherSuites">
<Array type="String">
<Item>TLS_ECDHE.*</Item>
<Item>TLS_AES.*</Item>
<Item>TLS_RSA.*</Item>
</Array>
</Set>
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>.*NULL.*</Item>
<Item>.*RC4.*</Item>
<Item>.*MD5.*</Item>
<Item>.*DES.*</Item>
<Item>.*DSS.*</Item>
<Item>TLS_DHE.*</Item>
</Array>
</Set>
</Configure>

上記ファイルを参照するように /opt/jetty-base/modules/idp-backchannel.mod に追記します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

(省略)

[xml]
etc/idp-backchannel.xml
etc/tweak-ssl.xml


4. httpd の設定

以下のように設定ファイルの修正を行います。

/etc/httpd/conf/httpd.conf の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

(省略)
#ServerName ex-idp-test??.gakunin.nii.ac.jp:80 ← ??は各自割り振られた番番号(0番なら「00」
↑コメントアウト(#)を削除
(省略)

/etc/httpd/conf.d/ssl.conf の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

...

# ls -dl /var/run/tomcat
drwxr-xr-x 2 root root 4096 Jun 20 16:21 /var/run/tomcat
            
↑このディレクトリが存在し、かつ所有者・グループが tomcat tomcat でなければ以下を実行
# chown -R tomcat:tomcat /var/run/tomcat

(省略)
<VirtualHost _default_:443>

(省略)
#ServerName ex-idp-test??.gakunin.nii.ac.jp:443 ← ??は各自割り振られた番号(0番なら「00」
↑コメントアウト(#)を削除
↓以下を追加
RequestHeader set X-Forwarded-Port 443
RequestHeader set X-Forwarded-Proto https

RequestHeader unset Forwarded
RequestHeader unset X-Forwarded-For
ProxyPass /idp/ http://localhost:8080/idp/ connectiontimeout=5 timeout=15

(省略)

/etc/httpd/conf.d/virtualhost-localhost80.conf の作成

これはShibboleth IdPが提供するreload-metadata.sh等のコマンドを使った操作を可能にするためのものです。

パネル
bgColor#eeeeee

<VirtualHost localhost:80>
ProxyPass /idp/ http://localhost:8080/idp/ connectiontimeout=5 timeout=15
</VirtualHost>

...


...

アンカー
idpInst4
idpInst4

4. Shibbolethのインストール 

各ファイル名等の指定は,Version 34.2.1に準拠しています。

1.   インストール

Shibboleth IdPのパッケージは、「/root/PKG」配下にあります。

...

 shibboleth-identity-provider-34.?.?.tar.gz がすでに配置されているので、以下のコマンドを実行してください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# tar xzvf shibboleth-identity-provider-34.?.?.tar.gz
# cd shibboleth-identity-provider-34.?.?
# ./bin/install.sh -Didp.conf.credentials.filemode=640 -Didp.conf.credentials.group=jetty

 install.shシェルスクリプトを実行すると、以下のような問い合わせがあります。
手順に従って、進めてください。

注意

インストール時に入力するパスワードを本運用で使う場合は、推測されにくいものを使用してください。
※ここで入力したパスワードは、/opt/shibboleth-idp/credentials/secrets.propertiesに記載されます。(平文)(cookiepassのほう)
※backpassのほうは記載されません。/opt/shibboleth-idp/confcredentials/idp.propertiesに記載されます。(平文)-backchannel.p12の暗号化のために使用されます。(本技術ガイドではidp-backchannel.p12を使用しません)

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

Buildfile: /root/PKG/shibboleth-identity-provider-4.2.1/bin/build.xml

install:
Source (Distribution) Directory (press <enter> to accept default): [/root/PKG/shibboleth-identity-provider-4.3.1.2] ?
[Enter] ←入力なし

Installation Directory: [/opt/shibboleth-idp] ?
[Enter] ←入力なし
New Install. Version: 4.3.1
Hostname: [ip-??-?-?-???.ap-northeast-1.compute.internal]

ex-idp-test??.gakunin.nii.ac.jp[Enter] ??は各自割り振られた番号(0番なら「00」
 (省略)
Backchannel PKCS12 Password: backpass[Enter] ←任意のパスワード(不使用)

Re-enter password: backpass[Enter]

 (省略)
Cookie Encryption Key Password: cookiepass[Enter] 
入力なし ※表示されたホスト名が違う場合、設定してください。←任意のパスワード(内部で使用)
Re-enter password: cookiepass[Enter]
 (省略)
SAML EntityID: [https://
ex-idp-test??.gakunin.nii.ac.jp/idp/shibboleth] ?
[Enter] ←入力なし
Attribute Scope: [
gakunin.nii.ac.jp]
nii.ac.jp [Enter] nii.ac.jpを設定してください。

Backchannel PKCS12 Password: backpass[Enter] ←任意のパスワード

Re-enter password: backpass[Enter]


Cookie Encryption Key Password: cookiepass[Enter] ←任意のパスワード
Re-enter password: cookiepass[Enter]

 (省略)

BUILD SUCCESSFUL
Total time: 2 minutes 9 seconds

 (省略)

 上記のような質問に答えながら、インストールを行います。

2. パーミッションの調整 

Jettyは、”jetty”ユーザで実行しているので、ログファイルを出力できるようディレクトリの所有者を変更します。Tomcatを”tomcat”ユーザで実行する場合は、ログファイルを出力できるようディレクトリの所有者を変更します。
同様に、設定ファイルやメタデータの保存ディレクトリなどの所有者・パーミッションも変更します。

...

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

#

chown

-R

tomcat

jetty:

tomcat

jetty /opt/shibboleth-idp/logs
#

chgrp -R tomcat

chgrp jetty /opt/shibboleth-idp/

conf
# chmod -R g+r /opt/shibboleth-idp/conf
# find /opt/shibboleth-idp/conf -type d -exec chmod -R g+s {} \;
# chgrp tomcat /opt/shibboleth-idp/

metadata
#

chmod

g+w

/opt/shibboleth-idp/metadata
#

chmod

+t

/opt/shibboleth-idp/metadata

ヒント

IdPが実際に使用する証明書の秘密鍵はまだ配置されておりませんので、所有者・パーミッションは後の手順で設定します。


アンカー
jakarta-taglibs-core.jar_jakarta-taglibs-standard.jar
jakarta-taglibs-core.jar_jakarta-taglibs-standard.jar

...

3

...

jstl-1.2.jar の配置 

 IdPの動作に必要なjstl.jar(jakarta-taglibs-core.jar と jakarta-taglibs-standard.jar)を配置します。
CentOS7の場合、jakarta-taglibs-standardパッケージに入っているので、 yum でインストールします。
※jstlの別途インストールは不要


4. ディレクトリインデックスの禁止

edit-webapp内にweb.xml を作成します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

#

yum install jakarta-taglibs-standard

cp -ip /opt/shibboleth-idp/dist/webapp/WEB-INF/web.xml /opt/shibboleth-idp/edit-webapp/WEB-INF/web.xml
# chmod u+w /opt/shibboleth-idp/edit-webapp/WEB-INF/web.xml

作成したweb.xml を以下の内容で修正します。

※既存の<servlet>の前に設定を追加します。/usr/share/java 配下にインストールされているので、edit-webapp/ 配下にシンボリックリンクを作成し、idp.warに含めます。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<filter-mapping>
<filter-name>SLF4JMDCServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Servlets and servlet mappings -->
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet>
<servlet-name>idp</servlet-name>

以下を実行して反映させます。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

#

# ln -s /usr/share/java/jakarta-taglibs-core.jar /opt/shibboleth-idp/edit-webapp/WEB-INF/lib/jakarta-taglibs-core.jar
# ln -s /usr/share/java/jakarta-taglibs-standard.jar

/opt/shibboleth-idp/

edit-webapp/WEB-INF/lib/jakarta-taglibs-standard.jar
#

bin/build.sh

 build.shシェルスクリプトを実行すると、以下のような問い合わせがあります。
手順に従って、進めてください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

Buildfile: /opt/shibboleth-idp/bin/build.

sh

xml

build-war:
Installation

Directory:

[/opt/shibboleth-idp] ?
[Enter] ←入力なし

Rebuilding

/opt/shibboleth-idp/war/idp.war

...
...done
BUILD SUCCESSFUL
Total time: 3 seconds

4. idp.war の登録 

${CATALINA_BASE}/conf/Catalina/localhost/idp.xml という新規ファイルを以下の内容で作成し、idp.warをTomcatが認識できるようにします。

<Context docBase=", Version 4.3.1
Initial populate from /opt/shibboleth-idp/dist/webapp to /opt/shibboleth-idp/webpapp.tmp
Overlay from /opt/shibboleth-idp/war/idp.war"

         privileged="true"
         antiResourceLocking="false"
         swallowOutput="true">
    <Manager pathname="" />
    <!-- Work around lack of Max-Age support in IE/Edge -->
    <CookieProcessor alwaysAddExpires="true" />
</Context>

...

edit-webapp to /opt/shibboleth-idp/webpapp.tmp
Creating war file /opt/shibboleth-idp/war/idp.war


BUILD SUCCESSFUL

(省略)


httpdの再起動とJettyの起動を行います。(すでにJettyが起動している場合はstopしてから行ってください)

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# systemctl restart httpd
# systemctl start tomcat

Tomcatの起動後、${CATALINA_BASE}/logs/catalina.{日付}.logにエラーが出力されていない事を確認してください。

ヒント
titleヒント

※catalina.{日付}.logにTomcat終了時(再起動時)のタイミングで以下のようなエラーが表示されることがありますが問題ありませんので無視してください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
致命的: A web application appears to have started a TimerThread named [Timer-0] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled.
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
致命的: A web application created a ThreadLocal with key of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase$1@XXXXXXXX]) and a value of type [java.lang.Boolean] (value [false]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.

(関連するバグレポート)

jetty
注意

Jettyに関する注意事項

  • jetty起動に失敗したら設定修正後、/opt/jetty-base/tmp/下にファイルが残っていたら削除してから再度起動してください。
  • build.shしたら sudo systemctl restart jetty しないと反映されません。

...


...

アンカー
idpInst5
idpInst5

5. サービスの起動・停止方法

サービス起動コマンド停止コマンド再起動コマンド
httpdsystemctl start httpdsystemctl stop httpdsystemctl restart httpd
tomcat
jettysystemctl start
tomcat
jettysystemctl stop
tomcat
jettysystemctl restart
tomcat

...

jetty


...

インストールが完了したら,サイト情報等の設定を行って下さい.

...