Mylar Connector with SSL Client Certificate
8
Jan
Jan
0
源起
mylay 的連接器目前沒有提供 SSL Client Certificate 設定, 需要在 eclipse 上面作些設定,同時改一下 mylar 的程式。
參考
- Add support for HTTP Digest authentication to Trac connector
- Guide to Remote repository access through authenticated HTTPS
- 為高級 JSSE 開發人員定制 SSL
eclipse.ini
目前要改 mylar ui 會需要動比較多,所以這裡用 system property 直接穿 進去用。
改這個 ini 檔的時候,注意不要多出空白等資料,不然會讀不進去,可以 開起來後,用 Help-About-Configuration Details 看看。
-vmargs -Xms512m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8 -Dmylar.trustStore=trust.jks -Dmylar.keyStore=haha.pfx -Dmylar.trustStorePassword="trustpass" -Dmylar.keyStorePassword="hahapass"
org.eclipse.mylar.tasks.core.web.WebClientUtil.SslClientAuthProtocolSocketFactory
只是改一下 SslProtocolSocketFactory.java
private String trustStore =
System.getProperty("mylar.trustStore");
private String trustStorePassword =
System.getProperty("mylar.trustStorePassword");
private String keyStore =
System.getProperty("mylar.keyStore");
private String keyStorePassword =
System.getProperty("mylar.keyStorePassword");
protected KeyManager[] getKeyManagers() {...}
protected TrustManager[] getTrustManagers(){...}
private SSLContext getSslContext() {
if (sslContext == null) {
try {
TrustManager[] tms = getTrustManagers();
KeyManager[] kms = getKeyManagers();
sslContext = SSLContext.getInstance("SSL");
sslContext.init(kms, tms, null);
} catch (Exception e) {
MylarStatusHandler.log(e, "could not get SSL context");
}
}
return sslContext;
}
org.eclipse.mylar.tasks.core.web.WebClientUtil
再改個 setupHttpClient() 中使用的的部份就可以。
Protocol acceptAllSsl = new Protocol("https",
new SslClientAuthProtocolSocketFactory(proxySettings),
WebClientUtil.getPort(repositoryUrl));
觀察
- mylar 過不久應該會有 ui 介面可用,現在這樣可以先撐著用。