2005年11月 ぷららのbroachでブログを始める
2014年5月29日 ぷららのbroach終了でgoo blogに移行
2024年5月25日 goo blog移行後10年が経過した
2014年5月29日 ぷららのbroach終了でgoo blogに移行
2024年5月25日 goo blog移行後10年が経過した
Validate.java
import java.io.File;
import java.io.FileInputStream;
import java.security.Key;
import java.security.KeyException;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.Iterator;
import java.util.List;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.KeySelectorException;
import javax.xml.crypto.KeySelectorResult;
import javax.xml.crypto.XMLCryptoContext;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.Reference;
import javax.xml.crypto.dsig.SignatureMethod;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.KeyValue;
import javax.xml.crypto.dsig.keyinfo.X509Data;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element; //-- added
/**
* This is a simple example of validating an XML Signature using the JSR 105
* API. It assumes the key needed to validate the signature is contained in a
* KeyValue KeyInfo.
*/
public class Validate {
//
// Synopsis: java Validate [document]
//
// where "document" is the name of a file containing the XML document
// to be validated.
//
public static void main(String[] args) throws Exception {
String fileName = args[0];
// Instantiate the document to be validated
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document doc = dbf.newDocumentBuilder().parse(
new FileInputStream(fileName));
// Find Signature element
NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS,
"Signature");
if (nl.getLength() == 0) {
throw new Exception("Cannot find Signature element");
}
// Create a DOM XMLSignatureFactory that will be used to unmarshal the
// document containing the XMLSignature
XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
// Create a DOMValidateContext and specify a KeyValue KeySelector
// and document context
DOMValidateContext valContext = new DOMValidateContext(
new KeyValueKeySelector(), nl.item(0));
//-- added(外部ファイルのベースディレクトリを指定)
String cpath = new File(fileName).getParent();
cpath = "file://" + cpath.replace('\\', '/') + "/";
valContext.setBaseURI(cpath);
System.out.println("setBaseURI-> " + cpath);
//-- added(署名対象XMLエレメントのアトリビュートを指定)
// 申請用総合ソフト 登録通知
NodeList tg = doc.getElementsByTagName("BODY");
if ( tg.getLength() != 0 ) {
valContext.setIdAttributeNS( (Element)tg.item(0), null, "ID");
System.out.println("Find BODY element and setIdAttibute=\"ID\"");
}
// 医療費通知(保険組合)
NodeList tg1 = doc.getElementsByTagName("TEG700");
if ( tg1.getLength() != 0 ) {
valContext.setIdAttributeNS( (Element)tg1.item(0), null, "id");
System.out.println("Find TEG700 element and setIdAttribute=\"id\"");
}
// e-Tax( 所得税 RKO0010. 証明書更新 PTE0010, 電子申請等証明書 TEB120
NodeList tg2 = doc.getElementsByTagName("RKO0010");
if ( tg2.getLength() != 0 ) {
valContext.setIdAttributeNS( (Element)tg2.item(0), null, "id");
System.out.println("Find RKO0010 element and setIdAttribute=\"id\"");
}
NodeList tg3 = doc.getElementsByTagName("PTE0010");
if ( tg3.getLength() != 0 ) {
valContext.setIdAttributeNS( (Element)tg3.item(0), null, "id");
System.out.println("Find PTE0010 element and setIdAttribute=\"id\"");
}
NodeList tg4 = doc.getElementsByTagName("TEB120");
if ( tg4.getLength() != 0 ) {
valContext.setIdAttributeNS( (Element)tg4.item(0), null, "id");
System.out.println("Find TEB120 element and setIdAttribute=\"id\"");
}
// unmarshal the XMLSignature
XMLSignature signature = fac.unmarshalXMLSignature(valContext);
// Validate the XMLSignature (generated above)
boolean coreValidity = signature.validate(valContext);
// Check core validation status
if (coreValidity == false) {
System.err.println("Signature failed core validation");
boolean sv = signature.getSignatureValue().validate(valContext);
System.out.println("signature validation status: " + sv);
// check the validation status of each Reference
Iterator<?> i = signature.getSignedInfo().getReferences().iterator();
for (int j = 0; i.hasNext(); j++) {
boolean refValid = ((Reference) i.next()).validate(valContext);
System.out.println("ref[" + j + "] validity status: "
+ refValid);
}
} else {
System.out.println("Signature passed core validation");
}
}
/**
* KeySelector which retrieves the public key out of the KeyValue element
* and returns it. NOTE: If the key algorithm doesn't match signature
* algorithm, then the public key will be ignored.
*/
private static class KeyValueKeySelector extends KeySelector {
public KeySelectorResult select(KeyInfo keyInfo,
KeySelector.Purpose purpose, AlgorithmMethod method,
XMLCryptoContext context) throws KeySelectorException {
if (keyInfo == null) {
throw new KeySelectorException("Null KeyInfo object!");
}
SignatureMethod sm = (SignatureMethod) method;
List<?> list = keyInfo.getContent();
for (int i = 0; i < list.size(); i++) {
XMLStructure xmlStructure = (XMLStructure) list.get(i);
if (xmlStructure instanceof X509Data) {
PublicKey pk = null;
List<?> l = ((X509Data) xmlStructure).getContent();
if (l.size() > 0) {
X509Certificate cert = (X509Certificate) l.get(0);
pk = cert.getPublicKey();
//-- added(署名公開鍵のDNと有効期限を表示)
System.out.println("X509Certificate Subject -> " + cert.getSubjectX500Principal().getName() );
System.out.println("X509Certificate NotAfter -> " + cert.getNotAfter().toString() );
if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
return new SimpleKeySelectorResult(pk);
}
}
}
if (xmlStructure instanceof KeyValue) {
PublicKey pk = null;
try {
pk = ((KeyValue) xmlStructure).getPublicKey();
} catch (KeyException ke) {
throw new KeySelectorException(ke);
}
// make sure algorithm is compatible with method
if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
return new SimpleKeySelectorResult(pk);
}
}
}
throw new KeySelectorException("No KeyValue element found!");
}
// @@@FIXME: this should also work for key types other than DSA/RSA
static boolean algEquals(String algURI, String algName) {
//-- added(署名に指定されたアルゴリズム)
System.out.println("Algorithm: " + algURI );
if (algName.equalsIgnoreCase("DSA")
&& algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)) {
return true;
} else if (algName.equalsIgnoreCase("RSA")
&& algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA256)) {
return true;
//-- added (sha1も対象とする設定)
} else if (algName.equalsIgnoreCase("RSA")
&& algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
return true;
} else {
return false;
}
}
}
private static class SimpleKeySelectorResult implements KeySelectorResult {
private PublicKey pk;
SimpleKeySelectorResult(PublicKey pk) {
this.pk = pk;
}
public Key getKey() {
return pk;
}
}
}
$ javac Validate.java
~/java.security jdk.xml.dsig.secureValidationPolicy=\ disallowAlg http://www.w3.org/TR/1999/REC-xslt-19991116,\ disallowAlg http://www.w3.org/2001/04/xmldsig-more#rsa-md5,\ disallowAlg http://www.w3.org/2001/04/xmldsig-more#hmac-md5,\ disallowAlg http://www.w3.org/2001/04/xmldsig-more#md5,\ disallowAlg http://www.w3.org/2000/09/xmldsig#dsa-sha1,\ disallowAlg http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1,\ disallowAlg http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1,\ maxTransforms 5,\ maxReferences 30,\ disallowReferenceUriSchemes http https,\ minKeySize RSA 1024,\ minKeySize DSA 1024,\ minKeySize EC 224,\ noDuplicateIds,\ noRetrievalMethodLoops # disallowAlg http://www.w3.org/2000/09/xmldsig#sha1,\ # disallowAlg http://www.w3.org/2000/09/xmldsig#rsa-sha1,\ # disallowReferenceUriSchemes file http https,\
~/logging.properties
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.FileHandler.level = FINER
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
org.jcp.xml.dsig.internal.level = FINER
com.sun.org.apache.xml.internal.security.level = FINER
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Users/someone/Documents/ShinseiyoSogoSoft/申請案件/2/取得公文書/complete_0001/complete_0001.xml
setBaseURI-> file:///Users/someone/Documents/ShinseiyoSogoSoft/申請案件/2/取得公文書/complete_0001/
Find BODY element and setIdAttibute="ID"
X509Certificate Subject -> CN=Registrar99,OU=XXXX Branch Bureau,OU=Nagano District Legal Affairs Bureau,OU=Ministry of Justice,O=Japanese Government,C=JP
X509Certificate NotAfter -> Tue Jan 14 23:59:59 JST 2025
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Users/someone/Documents/登記関連/署名テスト/test/test.xml
setBaseURI-> file:///Users/someone/Documents/登記関連/署名テスト/test/
X509Certificate Subject -> CN=202299999999990000099999993B,L=XXXX,L=Tokyo-to,C=JP
X509Certificate NotAfter -> Mon Jan 99 23:59:59 JST 2027
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Users/someone/Documents/登記関連/建物/tatemono00001/tatemono00001.tif.sig.xml
setBaseURI-> file:///Users/someone/Documents/登記関連/建物/tatemono00001/
X509Certificate Subject -> CN=202299999999990000099999993B,L=XXXX,L=Tokyo-to,C=JP
X509Certificate NotAfter -> Mon Jan 99 23:59:59 JST 2027
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Volumes/home/確定申告/令和5年度-2023/IK2023999999999900099999_01.xml
setBaseURI-> file:///Volumes/home/確定申告/令和5年度-2023/
Find TEG700 element and setIdAttribute="id"
X509Certificate Subject -> CN=Taro Urashima,OU=SA000000009999,OU=DIACERT Service,O=DIACERT CA,C=JP
X509Certificate NotAfter -> Wed Dec 31 23:59:59 JST 2025
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Volumes/someone/確定申告/令和4年度-2022/令和04年度\(所得税\)-署名後の保存.xtx
setBaseURI-> file:///Volumes/home/確定申告/令和4年度-2022/
Find RKO0010 element and setIdAttribute="id"
X509Certificate Subject -> CN=202299999999990000099999993B,L=XXXX,L=Tokyo-to,C=JP
X509Certificate NotAfter -> Mon Jan 99 23:59:59 JST 2027
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Volumes/home/確定申告/令和4年度-2022/受信データー証明書更新20230210102741679313.xtx
setBaseURI-> file:///Volumes/home/確定申告/令和4年度-2022/
Find PTE0010 element and setIdAttribute="id"
X509Certificate Subject -> CN=202299999999990000099999993B,L=XXXX,L=Tokyo-to,C=JP
X509Certificate NotAfter -> Mon Jan 99 23:59:59 JST 2027
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Volumes/home/確定申告/平成27年度-2015/電子申請等証明書20160201134148979316.xml
setBaseURI-> file:///Volumes/home/確定申告/平成27年度-2015/
Find TEB120 element and setIdAttribute="id"
X509Certificate Subject -> CN=uketsuke.e-tax.nta.go.jp,OU=Ministry of Finance,O=Japanese Government,C=JP
X509Certificate NotAfter -> Mon Oct 31 23:59:59 JST 2016
Algorithm: http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
Signature passed core validation
$ java -Djava.util.logging.config.file=./logging.properties -Djava.security.properties=./java.security Validate /Volumes/home/確定申告/平成27年度-2015/受信データ20160201134148979316.xtx
setBaseURI-> file:///Volumes/home/確定申告/平成27年度-2015/
Find RKO0010 element and setIdAttribute="id"
X509Certificate Subject -> CN=20159999999901A,L=XXXX,L=Tokyo-to,C=JP
X509Certificate NotAfter -> Mon Oct 08 23:59:59 JST 2018
Algorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1
Signature passed core validation
complete_0001.xml
<DOC>
<FRONT>
<SECRECY/>
<STAMP/>
</FRONT>
<BODY ID="DOCBODY"/>
<APPENDIX ID="moj.go.jp">
<DOCLINK REF="FH99999999999999999.pdf"/>
</APPENDIX>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#" Id="moj.go.jp9999999999999">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<Reference URI="#DOCBODY">
<Transforms>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<DigestValue>saHmngQNqMio4nIoyfMgptK7X+3RNkAi0AYSI5SfJxc=</DigestValue>
</Reference>
<Reference URI="FH99999999999999999.pdf">
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<DigestValue>95Sy9fTQcqQUlv9pswC5LgPOTO8BFU7PHmmo7EDQ6qA=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>NZ82/loKx96h8YyiE0ZNrx0OlsQRNxsxUnzLRw5vqi7/yk5D9j7VNp0PMes3AktvGtxVahfGG1RQ
bdADMPLVUj1RC5LSdwfww1upecTORt//aBZagUKUYJ7UdH79Pi+n/z9iGCJ08Fsx3Abwept6RFZJ
XJOdyGexIwj14OGxMoF4qnfAFFfnWtu2Lfy4EeJJO4JI5RIdjmhWbVyKDWtwHiEknTcAqOyOJQTX
pwcoHVjff/KOClL1cdAPTeyhXoNRsWFl4qdpitKubW8By01viGurul7Buvnl15v3lptHvx+iux5O
bJSFZXYGCwuynQELUBZAuTZ4EKVGv8mVgmYldw==</SignatureValue>
<KeyInfo>
<X509Data>
登記官の官職証明書
<X509Certificate>MIIFej..................................9mXSBE=</X509Certificate>
官職証明書のルート証明書
<X509Certificate>MIIEBDCCAuygAwIBAgIPNzI4MDQyMzYwNDg2MzczMA0GCSqGSIb3DQEBCwUAMEYxCzAJBgNVBAYT
AkpQMRwwGgYDVQQKDBNKYXBhbmVzZSBHb3Zlcm5tZW50MRkwFwYDVQQLDBBPZmZpY2lhbFN0YXR1
c0NBMB4XDTE5MDgyMzE1MDAwMFoXDTI5MDgyMzE0NTk1OVowRjELMAkGA1UEBhMCSlAxHDAaBgNV
BAoME0phcGFuZXNlIEdvdmVybm1lbnQxGTAXBgNVBAsMEE9mZmljaWFsU3RhdHVzQ0EwggEiMA0G
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkaCKUqxDTGx50NrhjVYKvvAYTlrmidWexGpna7JXx
SQFi0umtGe904ZbZOwSld8gxXqRJCxLx64ZUtPG25hHgYnCfxhkIA+p3nomgkwGrauSHsdBU9co9
ioKUAHPWpsp1CR2EFhE13NBBX2anxnqxil1KvInGOOl/Hf9mJ5Jz85oLgZHWxMDtRrKL2fPgXZ72
+YHv5QsyqZwFy3J9qPnQueUM7lSoYNidlyiIyhbtC8/68OH513nnksv+w65qEuXJh/LNj/y0ruAB
V3EyjHbd4oWyf7HHD4JO8ITa5ABMt2kSc91IxaSeJDBvD0rUbf4bOSnshTyQaN/gJL7Wc4xZAgMB
AAGjge4wgeswHQYDVR0OBBYEFFIm8Y7mfjbpZKQk94zYbSJcqFWZMA4GA1UdDwEB/wQEAwIBBjBO
BgNVHREERzBFpEMwQTELMAkGA1UEBhMCSlAxGDAWBgNVBAoMD+aXpeacrOWbveaUv+W6nDEYMBYG
A1UECwwP5a6Y6IG36KqN6Ki85bGAMFkGA1UdHwRSMFAwTqBMoEqkSDBGMQswCQYDVQQGEwJKUDEc
MBoGA1UECgwTSmFwYW5lc2UgR292ZXJubWVudDEZMBcGA1UECwwQT2ZmaWNpYWxTdGF0dXNDQTAP
BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCjy1OYTCLtF1mViU3uLdA2BtbOH+qa
RqQkhJTT5Mbqblwhp+I1TaHwO7kT0Tnw74f4e2nkUd5ByMyodojFk3+/Xj1CMG56dYjDkC8GBR8+
QdrEzDF4o6nui9xqMfzyevMFasaRdMSyWpeSjCquMJjkgc5l691Rwn2ixoEUol+tfhwmKVkQttUq
Bwu5ofnwTF814RTMh4IJFQL4UloXRkRBduNh+xLvWf7sBjirI7FrLfkvkkz7YAS1ToGkEGSb+CU3
8GHXwH3oul8/5SUZriNXUexKwLqzCjjqUsca2bDDP8A7myX7zdMNKWMhweSbOpedzaR+gF2Lrsx4
wU0AP+AY</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</DOC>
XMLドキュメント ID=#DOCBODY
$ echo -n '<BODY ID="DOCBODY"/>' | xmllint --c14n - | openssl dgst -sha256 -binary | base64
saHmngQNqMio4nIoyfMgptK7X+3RNkAi0AYSI5SfJxc=
$ openssl dgst -sha256 -binary %userprofile%/Documents/ShinseiyoSogoSoft/申請案件/2/取得公文書/complete_0001/FH99999999999999999.pdf | base64
95Sy9fTQcqQUlv9pswC5LgPOTO8BFU7PHmmo7EDQ6qA=
$ xmllint --c14n complete_0001.xml | sed -e ':L' -e 'N' -e '$!bL' -e 's/^.*\(<SignedInfo>.*<\/SignedInfo>\).*$/\1/' -e 's!<SignedInfo>!<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">!' | openssl dgst -sha256 -binary | hexdump -C
00000000 70 5c 89 89 5d 03 bd fc 81 18 85 5c 8c 72 bc 1d |p\..]......\.r..|
00000010 70 62 31 91 b6 bc 86 fa 43 b2 55 08 93 a4 be e2 |pb1.....C.U.....|
00000020
$ echo -n "MIIFejCCBGKgAwIBA..................merJAsVTeICCFn9mXSBE=" | base64 -d | openssl x509 -text -noout -inform der
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
39:39:39:39:39:39:39:39:39:39:39:39:39:39:39
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=JP, O=Japanese Government, OU=OfficialStatusCA
Validity
Not Before: Jan 14 15:00:00 2020 GMT
Not After : Jan 14 14:59:59 2025 GMT
Subject: C=JP, O=Japanese Government, OU=Ministry of Justice, OU=Nagano District Legal Affairs Bureau, OU=XXXX Branch Bureau, CN=Registrar99
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:c9:5b:4f:25:b4:c6:6a:47:d4:fa:62:81:15:62:
f6:2b:c4:ff:7e:26:d9:60:17:c8:f5:62:c2:f0:9e:
d9:5a:60:de:c5:a1:48:e5:a9:bc:34:11:76:66:28:
d3:4c:5e:5c:09:67:f2:93:0a:eb:4a:b7:85:c5:08:
b0:97:35:33:9e:7c:5c:18:f3:6f:60:e1:43:cb:d2:
56:62:11:5e:a4:de:4a:0a:be:18:61:33:8c:6c:43:
5d:5e:c9:2e:0a:b2:34:4b:38:74:75:1f:c8:3a:ce:
69:3d:82:b5:cb:c2:fe:f1:86:ca:96:93:42:e1:e4:
d4:19:e8:41:65:19:30:70:e8:16:03:32:3b:0e:2b:
0e:6e:84:2e:76:f3:0b:81:15:6b:fd:1e:ee:99:2b:
d2:39:82:ff:af:3f:4b:b8:0f:02:93:8c:15:61:fd:
3f:7b:a2:1a:4a:d0:2a:52:20:9b:ba:59:13:73:11:
3f:f9:f3:e5:40:4a:b8:55:e0:40:5c:67:4d:c6:11:
69:96:b9:64:51:70:49:9f:a7:4b:78:c0:7e:43:f5:
41:fb:61:86:cc:b4:6d:63:e0:b1:e2:d4:c1:c2:f3:
96:e8:87:9a:75:3c:36:4f:56:0d:6b:2b:5b:50:14:
7c:9f:b9:e2:ae:fa:f5:c7:a8:76:88:ca:a4:7b:75:
ab:f5
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Authority Key Identifier:
keyid:52:26:F1:8E:E6:7E:36:E9:64:A4:24:F7:8C:D8:6D:22:5C:A8:55:99
X509v3 Subject Key Identifier:
C9:C8:64:C9:3F:D4:83:24:12:F5:D8:66:E1:E9:7D:C1:32:0F:A8:73
X509v3 Key Usage: critical
Digital Signature, Non Repudiation
X509v3 Certificate Policies: critical
Policy: 0.2.440.100145.8.3.1.1.110
CPS: https://www.gpki.go.jp/osca/cpcps/index.html
X509v3 Subject Alternative Name:
DirName:/C=JP/O=\xE6\x97\xA5\xE6\x9C\xAC\xE5\x9B\xBD\xE6\x94\xBF\xE5\xBA\x9C/OU=\xE6\xB3\x95\xE5\x8B\x99\xE7\x9C\x81/OU=\xE9\x95\xB7\xE9\x87\x8E\xE5\x9C\xB0\xE6\x96\xB9\xE6\xB3\x95\xE5\x8B\x99\xE5\xB1\x80/OU=\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
X509v3 Issuer Alternative Name:
DirName:/C=JP/O=\xE6\x97\xA5\xE6\x9C\xAC\xE5\x9B\xBD\xE6\x94\xBF\xE5\xBA\x9C/OU=\xE5\xAE\x98\xE8\x81\xB7\xE8\xAA\x8D\xE8\xA8\xBC\xE5\xB1\x80
X509v3 CRL Distribution Points:
Full Name:
DirName: C = JP, O = Japanese Government, OU = OfficialStatusCA
Signature Algorithm: sha256WithRSAEncryption
73:df:b3:f2:15:93:df:bb:90:3b:99:ab:8f:3d:44:2d:11:d8:
56:29:9e:30:c3:76:cc:8e:93:ad:55:83:83:76:9a:47:31:3f:
2a:34:5b:bb:ee:cc:47:c4:9f:c0:d6:76:85:ae:7f:b5:97:27:
60:21:68:20:f0:d7:34:8f:14:22:4f:12:91:8e:1b:f8:d1:6c:
27:de:d7:04:e8:24:70:de:0d:20:10:29:db:d5:24:8a:90:ae:
fa:0e:17:d1:7b:77:36:ec:65:95:62:b1:03:a3:1a:b5:e1:82:
b5:47:27:02:8c:83:17:c4:31:52:30:fe:96:e5:5b:c8:e8:37:
3f:35:65:fb:62:fb:c9:b5:f6:ca:e7:32:1b:6d:59:ab:02:f7:
5c:bd:67:17:bd:63:59:eb:f2:45:b2:07:9d:e6:0f:eb:44:04:
18:c4:e4:09:b8:8b:ca:06:f1:4b:70:ee:a0:55:10:f4:e6:e9:
8e:12:e8:76:a6:59:97:1b:9f:07:55:21:69:76:cd:bc:a1:90:
50:17:74:14:29:97:50:7e:fb:88:95:18:5a:78:a7:05:a1:7c:
b7:1f:bc:f8:09:22:e6:09:07:fd:a3:e0:51:1a:76:14:61:55:
f4:1b:ec:b9:cf:6a:70:e6:7a:b2:40:b1:54:de:20:20:85:9f:
d9:97:48:11
$ echo -n "MIIFejCCBGKgAwIBA..................merJAsVTeICCFn9mXSBE=" | base64 -d | openssl x509 -pubkey -noout -inform der
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyVtPJbTGakfU+mKBFWL2
K8T/fibZYBfI9WLC8J7ZWmDexaFI5am8NBF2ZijTTF5cCWfykwrrSreFxQiwlzUz
nnxcGPNvYOFDy9JWYhFepN5KCr4YYTOMbENdXskuCrI0Szh0dR/IOs5pPYK1y8L+
8YbKlpNC4eTUGehBZRkwcOgWAzI7DisOboQudvMLgRVr/R7umSvSOYL/rz9LuA8C
k4wVYf0/e6IaStAqUiCbulkTcxE/+fPlQEq4VeBAXGdNxhFplrlkUXBJn6dLeMB+
Q/VB+2GGzLRtY+Cx4tTBwvOW6IeadTw2T1YNaytbUBR8n7nirvr1x6h2iMqke3Wr
9QIDAQAB
-----END PUBLIC KEY-----
$ echo -n "MIIFejCCBGKgAwIBA..................merJAsVTeICCFn9mXSBE=" | base64 -d | openssl x509 -pubkey -noout -inform der > tmppub.pem
$ echo -n 'NZ82/loKx96h8YyiE0ZNrx0OlsQRNxsxUnzLRw5vqi7/yk5D9j7VNp0PMes3AktvGtxVahfGG1RQ
bdADMPLVUj1RC5LSdwfww1upecTORt//aBZagUKUYJ7UdH79Pi+n/z9iGCJ08Fsx3Abwept6RFZJ
XJOdyGexIwj14OGxMoF4qnfAFFfnWtu2Lfy4EeJJO4JI5RIdjmhWbVyKDWtwHiEknTcAqOyOJQTX
pwcoHVjff/KOClL1cdAPTeyhXoNRsWFl4qdpitKubW8By01viGurul7Buvnl15v3lptHvx+iux5O
bJSFZXYGCwuynQELUBZAuTZ4EKVGv8mVgmYldw==' | base64 -d | openssl rsautl -verify -asn1parse -inkey tmppub.pem -pubin
0:d=0 hl=2 l= 49 cons: SEQUENCE
2:d=1 hl=2 l= 13 cons: SEQUENCE
4:d=2 hl=2 l= 9 prim: OBJECT :sha256
15:d=2 hl=2 l= 0 prim: NULL
17:d=1 hl=2 l= 32 prim: OCTET STRING
0000 - 70 5c 89 89 5d 03 bd fc-81 18 85 5c 8c 72 bc 1d p\..]......\.r..
0010 - 70 62 31 91 b6 bc 86 fa-43 b2 55 08 93 a4 be e2 pb1.....C.U.....
$
macOS(Version11.7.10)コンソールコマンドのecho, xmllint, sed, openssl, base64, hexdumpを使用
$ openssl s_client -4 -connect secure.plala.or.jp:587 -starttls smtp -quiet
depth=3 C = IE, O = Baltimore, OU = CyberTrust, CN = Baltimore CyberTrust Root
verify return:1
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, CN = DigiCert TLS RSA SHA256 2020 CA1
verify return:1
depth=0 C = JP, ST = Tokyo, L = Chiyoda-Ku, O = "NTT DOCOMO, INC.", CN = *.plala.or.jp
verify return:1
250 SIZE 20971520
ehlo localhost
250-msc12.plala.or.jp
250-AUTH=LOGIN PLAIN
250-AUTH LOGIN PLAIN
250-PIPELINING
250-DSN
250-8BITMIME
250 SIZE 20971520
quit
221 msc12.plala.or.jp ESMTP server closing connection
read:errno=0
①メールサーバ登録/修正
送信元アドレス: someone@somewhere.plala.or.jp
送信メールサーバー: secure.plala.or.jp
送信ポート: 587
セキュリティの種類: TLS
SMTP認証: 使用する
アカウント名:someone@somewhere.plala.or.jp
パスワード: himitunoaikotobahirakegoma
-------------
メール送信テストを行います: はい
②メールサーバ登録/修正
送信元アドレス: someone@somewhere.plala.or.jp
送信メールサーバー: secure.plala.or.jp
送信ポート: 465
セキュリティの種類: SSL
SMTP認証: 使用する
アカウント名:someone@somewhere.plala.or.jp
パスワード: himitunoaikotobahirakegoma
-------------
メール送信テストを行います: はい
③メールサーバ登録/修正
送信元アドレス: someone@somewhere.plala.or.jp
送信メールサーバー: secure.plala.or.jp
送信ポート: 587
セキュリティの種類: なし
SMTP認証: 使用する
アカウント名:someone@somewhere.plala.or.jp
パスワード: himitunoaikotobahirakegoma
-------------
メール送信テストを行います: はい
$ openssl s_client -4 -connect secure.plala.or.jp:587 -starttls smtp -no_tls1_1 -no_tls1_2 -quiet
4634283692:error:1400442E:SSL routines:CONNECT_CR_SRVR_HELLO:tlsv1 alert protocol version:/System/Volumes/Data/SWE/macOS/BuildRoots/37599d3d49/Library/Caches/com.apple.xbs/Sources/libressl/libressl-56.60.4/libressl-2.8/ssl/ssl_pkt.c:1200:SSL alert number 70
4634283692:error:140040E5:SSL routines:CONNECT_CR_SRVR_HELLO:ssl handshake failure:/System/Volumes/Data/SWE/macOS/BuildRoots/37599d3d49/Library/Caches/com.apple.xbs/Sources/libressl/libressl-56.60.4/libressl-2.8/ssl/ssl_pkt.c:585:
---
$ openssl s_client -4 -connect secure.plala.or.jp:587 -starttls smtp -no_tls1_2 -quiet
4367462060:error:1400442E:SSL routines:CONNECT_CR_SRVR_HELLO:tlsv1 alert protocol version:/System/Volumes/Data/SWE/macOS/BuildRoots/37599d3d49/Library/Caches/com.apple.xbs/Sources/libressl/libressl-56.60.4/libressl-2.8/ssl/ssl_pkt.c:1200:SSL alert number 70
4367462060:error:140040E5:SSL routines:CONNECT_CR_SRVR_HELLO:ssl handshake failure:/System/Volumes/Data/SWE/macOS/BuildRoots/37599d3d49/Library/Caches/com.apple.xbs/Sources/libressl/libressl-56.60.4/libressl-2.8/ssl/ssl_pkt.c:585:
---
$ openssl s_client -4 -connect secure.plala.or.jp:587 -starttls smtp -no_tls1_1 -no_tls1 -quiet
depth=3 C = IE, O = Baltimore, OU = CyberTrust, CN = Baltimore CyberTrust Root
verify return:1
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, CN = DigiCert TLS RSA SHA256 2020 CA1
verify return:1
depth=0 C = JP, ST = Tokyo, L = Chiyoda-Ku, O = "NTT DOCOMO, INC.", CN = *.plala.or.jp
verify return:1
250 SIZE 20971520
quit
221 msc12.plala.or.jp ESMTP server closing connection
read:errno=0
$ host secure.plala.or.jp
secure.plala.or.jp has address 60.36.166.237
NVR510 config
ip route 60.36.166.237/32 gateway pp 1 hide
$ openssl s_client -4 -connect secure.plala.or.jp:25 -starttls smtp -quiet
depth=3 C = IE, O = Baltimore, OU = CyberTrust, CN = Baltimore CyberTrust Root
verify return:1
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, CN = DigiCert TLS RSA SHA256 2020 CA1
verify return:1
depth=0 C = JP, ST = Tokyo, L = Chiyoda-Ku, O = "NTT DOCOMO, INC.", CN = *.plala.or.jp
verify return:1
250 SIZE 20971520
ehlo secure
250-msc13.plala.or.jp
250-AUTH=LOGIN PLAIN CRAM-MD5
250-AUTH LOGIN PLAIN CRAM-MD5
250-PIPELINING
250-DSN
250-8BITMIME
250 SIZE 20971520
mail from: someone@somewhere.plala.or.jp
553 Authentication is required to send mail as <someone@somewhere.plala.or.jp>
quit
221 msc13.plala.or.jp ESMTP server closing connection
read:errno=0
$ telnet secure.plala.or.jp 25
Trying 60.36.166.237...
Connected to secure.plala.or.jp.
Escape charcter is '^]'.
220 msc12.plala.or.jp ESTM server ready Fri, 29 Sep 2023 12:30:40 +0900
mail from: someone@somewhere.plala.or.jp
553 Authentication is required to send mail as <someone@somewhere.plala.or.jp>
quit
221 msc12.plala.or.jp ESTM server closing connection
Connection closed by foreign host.
11月の対応にて、「CRAM-MD5」が自動判別されないように
変更予定でございますので、お待ちいただきますよう
よろしくお願いいたします。