วันพุธที่ 30 พฤศจิกายน พ.ศ. 2554

Java TLS/SSL #2

ตัวอย่าง code JSSE


ตัวอย่างในการ Run
Server:
D:\java\TLS>java ClassFileServer 80 . TLS true

Client:
D:\java\TLS>java SSLSocketClientWithClientAuth 147.127.xxx.90 80 /index.html


Modify to support Client authentication:

ClassFileServer:
ks.load(new FileInputStream("keystore-147.127.xxx.90"), passphrase);
kmf.init(ks, passphrase);
KeyStore ksTrust = KeyStore.getInstance("JKS");
ksTrust.load(new FileInputStream("truststore-147.127.xxx.91"), null);
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(ksTrust);
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
===========================

SSLSocketClientWithClientAuth:
ks.load(new FileInputStream("keystore-147.127.xxx.91"), passphrase);
kmf.init(ks, passphrase);
KeyStore ksTrust = KeyStore.getInstance("JKS");
ksTrust.load(new FileInputStream("truststore-147.127.xxx.90"), null);
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(ksTrust);
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

===========================
Just swap truststore and keystore for each other.



Trust store เหมือน public key แต่ทำไมจึงมี password?
Ans:
NOTE: Trust stores often have passwords but for validation of credentials the password is not needed because public key certificates are publicly accessible in any key or trust store. If you supply a password, the KeyStore.load method will use it when loading the store but only to validate the integrity of non-public information during the load – never during actual use of public key certificates in the store. Thus, you may always pass null in the second argument to KeyStore.load. If you do so, only public information will be loaded from the store.

วันพฤหัสบดีที่ 24 พฤศจิกายน พ.ศ. 2554

P2PNS vs RELOAD

Interested P2PSIP security solutions

- P2PNS: เป็น p2p-sip overlay ที่ใช้ การ hash(public-key) ในการ create ID เพื่อป้องการพวก Sybil attack สามารถ config DHT algorithm ใช้งานผ่าน OpenSER ที่ติดต่อกับ overlay network ที่ได้จาก OverSim (ที่ Run ผ่าน Omnet++ อีกที)

default DHT algorithm คือ Kademlia

P2PNS ออกแบบมาเพื่อให้ peer เก็บค่าของ SIP AoR ที่ Peer เอง และ retrieve ผ่าน DHT algorithm แทนที่จะต้องไป Query ผ่าน Name Server (เลยตั้งชื่อว่า P2PNS) แต่ไม่ได้บอกรายละเอียดชัดเจน ของ security เกี่ยวกับ การรับส่งข้อมูล



- RELOAD: คล้าย ๆ กับ P2PNS แต่ กำหนดเงื่อนไข รายละเอียดการส่งข้อมูลเยอะกว่า มี security layer บังคับใช้ TLS/SSL รวมกับ PKI, มี Certificate server ไว้ตรวจสอบ กำหนดทุกการส่งต้องผ่าน TLS/SSL

default DHT algorithm คือ chord