Closed favccxx closed 2 years ago
These client connection errors usually means that the client is not configured with a CA certificate that matches the signer of the server's TLS certificate.
I've opened a PR to add some more TLS troubleshooting information to the Fabric docs that may help you: https://github.com/hyperledger/fabric/pull/3346 It is written from the perspective of a peer CLI client connection, but should be helpful for a Java SDK connection error as well.
What is the corresponding error in the peer log at the time of connection failure?
No response, closing.
I'm trying to generate certificate by java code, and I succeed to start orderer and peer, but I failed to create channel for grpcs error. I know there must something wrong with my tls certs. But i don't know the reason. Can you tell me the reason?
`Caused by: org.hyperledger.fabric.sdk.exception.TransactionException: Channel fucking, send transaction failed on orderer OrdererClient{id: 4, channel: fucking, name: fabric-orderer-oynp4ab7, url: grpcs://172.20.52.68:32101}. Reason: UNAVAILABLE: io exception
Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
Caused by: javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem
Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
Some Java codes:
`public static BaasCert generateNodeCert(String nodeType, String caType, String nodeName, String orgCode, String orgDomain, String nameSpace, String nodeSubject, Date startDate, Date endDate) throws BusinessException { Security.addProvider(new BouncyCastleProvider()); try { KeyPair keyPair = KeyPairUtils.generateFabricKeyPair(); String keyPem = FabricCertService.nodeKeyToPem(keyPair.getPrivate());
public static KeyPair generateFabricKeyPair() { KeyPair keyPair; try { ECGenParameterSpec ecSpec = new ECGenParameterSpec(SECP256R1); KeyPairGenerator kf = KeyPairGenerator.getInstance("EC"); kf.initialize(256, new SecureRandom()); kf.initialize(ecSpec, new SecureRandom()); keyPair = kf.generateKeyPair(); } catch (Exception e) { return null; } return keyPair; }
Below is my certificates, Hope you can tell me the reason.
` [ [ Version: V3 Subject: C=CN, ST=Beijing, L=Haidian, OU=madong + OU=orderer, CN=fabric-orderer-iwuwcbyf.madong.madong.com Signature Algorithm: SHA256withECDSA, OID = 1.2.840.10045.4.3.2
Key: Sun EC public key, 256 bits public x coord: 28785226202240756646177718527367595238983741204018410754881037527273160040806 public y coord: 76967145626319286917147553453023685935363700217575474759376991608531270167364 parameters: secp256r1 [NIST P-256, X9.62 prime256v1] (1.2.840.10045.3.1.7) Validity: [From: Thu Apr 21 20:26:05 GMT+08:00 2022, To: Wed Apr 21 20:26:05 GMT+08:00 2027] Issuer: CN=root.tlsca.xx.com, O=xxcom, L=Haidian, ST=BeiJing, C=CN SerialNumber: [ 0237977f 68fe997a ce5dbe05 945e7c3e 9aa1e909]
Certificate Extensions: 7 [1]: ObjectId: 1.2.3.4.5.6.7.8.1 Criticality=false Extension unknown: DER encoded OCTET string = 0000: 04 79 1B 77 7B 22 61 74 74 72 73 22 3A 7B 22 68 .y.w."attrs":."h 0010: 66 2E 41 66 66 69 6C 69 61 74 69 6F 6E 22 3A 22 f.Affiliation":" 0020: 6D 61 64 6F 6E 67 22 2C 22 68 66 2E 45 6E 72 6F madong","hf.Enro 0030: 6C 6C 6D 65 6E 74 49 44 22 3A 22 66 61 62 72 69 llmentID":"fabri 0040: 63 2D 6F 72 64 65 72 65 72 2D 69 77 75 77 63 62 c-orderer-iwuwcb 0050: 79 66 2E 6D 61 64 6F 6E 67 2E 6D 61 64 6F 6E 67 yf.madong.madong 0060: 2E 63 6F 6D 22 2C 22 68 66 2E 54 79 70 65 22 3A .com","hf.Type": 0070: 22 6F 72 64 65 72 65 72 22 7D 7D "orderer"..
[2]: ObjectId: 2.5.29.35 Criticality=false AuthorityKeyIdentifier [ KeyIdentifier [ 0000: 04 18 30 16 80 14 C0 F1 BB 2E AB 6A 70 7F 99 B1 ..0........jp... 0010: 05 CB A7 61 9C 36 60 03 8C F3 ...a.6`... ] ]
[3]: ObjectId: 2.5.29.19 Criticality=true BasicConstraints:[ CA:false PathLen: undefined ]
[4]: ObjectId: 2.5.29.37 Criticality=true ExtendedKeyUsages [ clientAuth serverAuth ]
[5]: ObjectId: 2.5.29.15 Criticality=true KeyUsage [ DigitalSignature ]
[6]: ObjectId: 2.5.29.17 Criticality=false SubjectAlternativeName [ DNSName: fabric-orderer-iwuwcbyf DNSName: fabric-orderer-iwuwcbyf.madong.madong.com DNSName: fabric-orderer-iwuwcbyf.35568e768fb66d2c8002 ]
[7]: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: EA 4E 1A 2D 66 A9 4E 57 94 43 98 D5 59 DB 92 70 .N.-f.NW.C..Y..p 0010: 4F 3F C2 53 O?.S ] ]
] Algorithm: [SHA256withECDSA] Signature: 0000: 30 44 02 20 42 2B 5D 3D 0C BB B9 94 1B 42 D2 C2 0D. B+]=.....B.. 0010: 98 D7 19 BE BE B9 44 58 60 D9 32 E0 B7 80 4C 91 ......DX`.2...L. 0020: BC 64 04 A2 02 20 66 C6 03 BE C6 42 B1 A4 B7 6A .d... f....B...j 0030: 93 BE AB EF 94 BC B7 81 C5 66 14 6D 45 DE B1 FB .........f.mE... 0040: 13 CD 52 FF 18 A1 ..R...
]`