Skip to content

Commit

Permalink
Release 2.2.1 (#491)
Browse files Browse the repository at this point in the history
* remove trimLeadingZeroes when encode publicKey of guomi (#485)

* fix the bug of sm2 verify && add the test case (#486)

* fix the bug of sm2 verify && add the test case

* add exception handling for network module. (#483)

* add socket connection to map when handshake success.

* add check for connectStr.

* add exception handling for network module.

* add print pem object info.

* add log print when load p12 or pem file.

* update handshake failed error message.

* delete the blank space (#489)

* delete the blank space

* modify error message

* update TransactionReceipt Log (#490)

* update release.txt ChangeLog.md (#492)

Co-authored-by: cyjseagull <[email protected]>
Co-authored-by: dalaocu <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2020
1 parent 8762269 commit ebda195
Show file tree
Hide file tree
Showing 18 changed files with 448 additions and 203 deletions.
15 changes: 15 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### v2.2.1

(2020-01-17)

* 更新
1. 添加网络模块的异常处理,给出更详细的错误信息

* 修复
1. 修正国密签名验签的bug
2. 修复国密交易RLP编码pub成员首部空字符被清理的bug

* 兼容
1. 适配fisco-bcos 2.2.0版本,支持Channel Message v1/V2/V3协议


### v2.2.0

(2019-12-24)
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.2.0
v2.2.1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void retrySendMessage() {
Random random = new SecureRandom();
Integer index = random.nextInt(fromConnectionInfos.size());

logger.debug("selected:{}", index);
logger.debug("selected index: {}, peer: {}", index, fromConnectionInfos.get(index));

setFromConnection(fromConnectionInfos.get(index));

Expand All @@ -90,7 +90,7 @@ public void retrySendMessage() {
logger.error("Failed to send message,all retry failed");

errorCode = ChannelMessageError.NODES_UNREACHABLE.getError();
throw new Exception("Failed to send message,all retry failed");
throw new Exception(" Failed to send message,all retry failed ");
}

ChannelHandlerContext ctx =
Expand All @@ -109,7 +109,7 @@ public void retrySendMessage() {
fromConnection.getHost(),
fromConnection.getPort());
} else {
logger.error("sending node unavailable");
logger.debug("sending node unavailable");

retrySendMessage();
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/fisco/bcos/channel/client/P12Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@
import org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.fisco.bcos.web3j.crypto.ECKeyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

public class P12Manager {

private static final Logger logger = LoggerFactory.getLogger(P12Manager.class);

private String p12File;
private final String NAME = "key";
private String password;
Expand All @@ -47,13 +52,17 @@ public void load()
Resource keyStoreResource = resolver.getResource(p12File);

keyStore.load(keyStoreResource.getInputStream(), password.toCharArray());

// logger.debug(" p12 load, keyStore: {}", keyStore);
}

public void load(InputStream in, String password)
throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException,
NoSuchProviderException {
keyStore = KeyStore.getInstance("PKCS12", "BC");
keyStore.load(in, password.toCharArray());

// logger.debug(" p12 load, keyStore: {}", keyStore);
}

public PrivateKey getPrivateKey()
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/fisco/bcos/channel/client/PEMManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
import org.fisco.bcos.web3j.crypto.ECKeyPair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

public class PEMManager {

private static final Logger logger = LoggerFactory.getLogger(PEMManager.class);

private PemObject pem;
private String pemFile;

Expand All @@ -56,6 +61,9 @@ public void load(InputStream in)
if (pem == null) {
throw new IOException("The file does not represent a pem account.");
}

// logger.debug(" load pem, type: {}, header: {}", pem.getType(), pem.getHeaders());

pemReader.close();
}

Expand Down
69 changes: 28 additions & 41 deletions src/main/java/org/fisco/bcos/channel/client/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -328,18 +329,13 @@ public void run() throws Exception {
while (true) {
Map<String, ChannelHandlerContext> networkConnection =
channelConnections.getNetworkConnections();
channelConnections.getReadWriteLock().readLock().lock();
try {
for (String key : networkConnection.keySet()) {
if (networkConnection.get(key) != null
&& ChannelHandlerContextHelper.isChannelAvailable(
networkConnection.get(key))) {
running = true;
break;
}

for (ChannelHandlerContext ctx : networkConnection.values()) {
if (Objects.nonNull(ctx)
&& ChannelHandlerContextHelper.isChannelAvailable(ctx)) {
running = true;
break;
}
} finally {
channelConnections.getReadWriteLock().readLock().unlock();
}

if (running || sleepTime > connectSeconds * 1000) {
Expand All @@ -350,31 +346,10 @@ public void run() throws Exception {
}
}

if (!running) {
logger.error("connectSeconds = {}", connectSeconds);

String errorMessage =
" Can not connect to nodes "
+ channelConnections.getConnectionsStr()
+ " ,groupId: "
+ String.valueOf(groupId)
+ " ,caCert: "
+ channelConnections.getCaCert()
+ " ,sslKey: "
+ channelConnections.getSslKey()
+ " ,sslCert: "
+ channelConnections.getSslCert()
+ " ,java version: "
+ System.getProperty("java.version");

logger.error(errorMessage);
throw new Exception(errorMessage);
}

logger.info(
" Connect to nodes ["
String baseMessage =
" nodes: "
+ channelConnections.getConnectionsStr()
+ "], groupId: "
+ " ,groupId: "
+ String.valueOf(groupId)
+ " ,caCert: "
+ channelConnections.getCaCert()
Expand All @@ -383,20 +358,32 @@ public void run() throws Exception {
+ " ,sslCert: "
+ channelConnections.getSslCert()
+ " ,java version: "
+ System.getProperty("java.version"));
+ System.getProperty("java.version")
+ " ,java vendor: "
+ System.getProperty("java.vm.vendor");

if (!running) {
String errorMessage = " Failed to connect to " + baseMessage;
logger.error(errorMessage);
throw new Exception(errorMessage);
}

logger.info(" Connect to " + baseMessage);

channelConnections.startPeriodTask();
eventLogFilterManager.start();
} catch (InterruptedException e) {
logger.error("system error ", e);
logger.warn(" thread interrupted exception: ", e);
Thread.currentThread().interrupt();
} catch (Exception e) {
logger.error("system error ", e);
logger.error(
" service init failed, error message: {}, error: ", e.getMessage(), e);
throw e;
}
}
}
if (flag == 0) {
throw new Exception("Please set the right groupId");
throw new Exception("Please set the right groupId ");
}
}

Expand Down Expand Up @@ -609,13 +596,13 @@ public void run(Timeout timeout) throws Exception {
bcosMessage.getSeq());

} catch (Exception e) {
logger.error("system error:{} ", e);
logger.error(" error message:{}, error: {} ", e.getMessage(), e);

BcosResponse response = new BcosResponse();
response.setErrorCode(-1);
response.setErrorMessage(
e.getMessage()
+ " Requset send failed! Can not connect to nodes success, please checkout the node status and the sdk config!");
+ " requset send failed! please check the log file content for reasons.");
response.setContent("");
response.setMessageID(request.getMessageID());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void run() {
Thread.currentThread().interrupt();
}

logger.debug(
logger.trace(
" event filter manager, filter: {}, callback: {}",
registerIDToFilter.size(),
filterIDToCallback.size());
Expand Down
Loading

0 comments on commit ebda195

Please sign in to comment.