---
title: "WeiboException: RSA premaster secret error"
author: "c_c"
date: "2014-03-11T10:09:08Z"
tags: []
categories: ["企业架构"]
slug: "weiboexception-rsa-premaster-secret-error"
draft: false
lastmod: "2014-03-11T10:14:44Z"
id: 2029267
url: "https://waddy.iteye.com/blog/2029267"
---

### 报错描述

在使用新浪微博API时，eclipse中调试没有问题，但是自己打的工程包却出了问题，报错如下：

 

```
WeiboException: RSA premaster secret error
        at org.waddy.weibo.http.HttpClient.httpRequest(HttpClient.java:422)
        ...
Caused by: javax.net.ssl.SSLKeyException: RSA premaster secret error
        at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(RSAClientKey
Exchange.java:99)
        ...
Caused by: java.security.NoSuchAlgorithmException: SunTlsRsaPremasterSecret KeyG
enerator not available
        at javax.crypto.KeyGenerator.<init>(DashoA13*..)
```

 

### 问题原因

原因在于用Eclipse创建一个新的Java应用程序时，Eclipse会在build path添加$JAVA\_HOME/jre/lib/ext目录下的四个jar：dnsns.jar，localedata.jar，sunjce\_provider.jar，sunpkcs11.jar。

 

### 解决办法

在你本地的jdk中找到上述jar包，放到你项目的lib目录（classpath）下即可。