比較バージョン

キー

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

IdPv4のインストール

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


目次
maxLevel2
minLevel2
stylenone


...

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にはJettyのパッケージがないので、ダウンロードしてインストールします。
実習セミナーでは予めダウンロードした「/root/PKG」内の、jetty-distribution-9.4.*.v????????.tar.gz を使います。
さらに、Shibboleth Projectが配布している各種設定ファイル群(jetty-base)を配置します。
こちらも予め「/root/PKG」内に配置してあるものを使用します。

...

"root"ユーザではなく、Jetty起動用のユーザを使用することを推奨します。
ここでは、一般的な "jetty" ユーザを作成します。(以降、"jetty"ユーザを使用する事が前提で説明します。)ユーザを使用する事を前提として説明します。)

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# groupadd -g 110 jetty
# useradd -r 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

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

jetty.serviceについては、コピー後に以下のように修正します。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

# sudo systemctl daemon-reload

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

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

JAVA=/usr/lib/jvm/jre/bin/java
JETTY_HOME=/opt/jetty
JETTY_BASE=/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の修正xml の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<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

# sudo mv # 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の作成
ini の作成
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# Any other required Jetty

コード ブロック
languagebash
# 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

# Strip IPv6 brackets #-Dorg.eclipse.jetty.util.HostPort.STRIP_IPV6=true

/opt/jetty-base/start.d/idp.ini の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

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

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

...

/opt/jetty-base/webapps/idp.xmlを以下のように修正します。(idp.warファイルのパス修正)

コード ブロック
languagebash
# /etc/profile.d/java-tomcat.sh - set Java and Tomcat stuff
JAVA_HOME=/usr/lib/jvm/java
#export MANPATH=$MANPATH:/usr/java/default/man
CATALINA_HOME=/usr/share/tomcat
CATALINA_BASE=$CATALINA_HOME
PATH=$JAVA_HOME/bin:$CATALINA_BASE/bin:$CATALINA_HOME/bin:$PATH
export PATH JAVA_HOME CATALINA_HOME CATALINA_BASE

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

パネル
bgColor#eeeeee

# source /etc/profile

5. Apache の設定

...

# ---------------------------------------
# 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

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

以下のように /etc/httpd/conf.d/ssl.conf を修正します。 

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

(省略)
<VirtualHost _default_:443>

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

6. Tomcat の設定

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

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

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

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

<!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 に追記します。※実習環境では、Connector port="8080" をコメントアウトします。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
<!--
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
-->

...

(省略)

[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

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->

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

...

(省略)
<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 4.2

...

4. Shibbolethのインストール 

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

1.   インストール

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

...

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

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

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

注意

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

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

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

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

Installation Directory: [/opt/shibboleth-idp] ?
[Enter] ←入力なし
New Install. Version: 4.3.1
Hostname: [ex-idp-testip-??-?-?-???.gakunin.nii.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を設定してください。

 (省略)

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

metadata
#

chmod

-R

g+

r

w /opt/shibboleth-idp/

conf

metadata
#

find

chmod +t /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

metadata

ヒント

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


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

3jstl-1.2.jar の配置 

 ※jstlの別途インストールは不要


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

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

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# cp -ip /opt/shibboleth-idp

/metadata
# chgrp tomcat /opt/shibboleth-idp/credentials/secrets.properties
# chmod g+r

/dist/webapp/WEB-INF/web.xml /opt/shibboleth-idp/

credentials/secrets.properties
# chgrp tomcat

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

credentials/sealer.*
# chmod g+r /opt/shibboleth-idp/credentials/sealer.*
ヒント

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

...

edit-webapp/WEB-INF/web.xml

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

※既存の<servlet>の前に設定を追加します。

パネル
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

...

3jstl-1.2.jar の配置 

 jstl-1.2.jarは、予め「/root/PKG」配下にあります。
edit-webapp/ 配下に配置し、idp.warに含めます。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

#

cp /root/PKG/jstl-1.2.jar

/opt/shibboleth-idp/

edit-webapp/WEB-INF/lib/
#

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

, Version 4.3.

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

4. idp.war の登録 

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

<Context docBase="1
Initial populate from /opt/shibboleth-idp/dist/webapp to /opt/shibboleth-idp/webpapp.tmp
Overlay from /opt/shibboleth-idp/edit-webapp to /opt/shibboleth-idp/webpapp.tmp
Creating war file /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>

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



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.

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

solid
# systemctl restart httpd
# systemctl start jetty
注意

Jettyに関する注意事項

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


...

アンカー
idpInst5
idpInst5

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

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


...

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

...