생각하는 족족 고.따.구 냐..

Posted
Filed under About Knowledge/OS_Linux
ip route add 172.17.19.0/24 via 10.8.0.13
2020/11/14 15:25 2020/11/14 15:25
Posted
Filed under About Knowledge/OS_Linux
yum install –y epel-release
yum install update -y
yum install -y openvpn
openvpn --config /경로/클라이언트명.ovpn
2020/11/13 15:58 2020/11/13 15:58
Posted
Filed under About Knowledge/Programs_Java
URL url = ${TARGET_CLASS}.class.getProtectionDomain().getCodeSource().getLocation();
2020/11/12 13:42 2020/11/12 13:42
Posted
Filed under About Knowledge/Programs_Java
java에서 x509 인증서(certificate)를 읽어온다.

            CertificateFactory fact = CertificateFactory.getInstance("X.509");
            FileInputStream is = new FileInputStream("./lib/license/felice.pem");
            result = (X509Certificate) fact.generateCertificate(is);
          
            // 인증서를 검증한다.
            result.verify( ${OTHER_CERT}.getPublicKey()
2020/11/12 13:41 2020/11/12 13:41
Posted
Filed under About Knowledge/Programs_Java
signed jar파일에서 인증서(certificate)를 읽어온다.

X509Certificate result = null;
        try {
            //InputStream in = X509Certificate.class.getResourceAsStream("classpath:META-INF/xxxxx.RSA");
            InputStream in = new ClassPathResource("META-INF/xxxxxx.RSA").getInputStream();
            byte[] buffer = in.readAllBytes();
            in.close();
            //Corresponding class of signed_data is CMSSignedData
            CMSSignedData signature = new CMSSignedData(buffer);
            Store cs = signature.getCertificates();
            SignerInformationStore signers = signature.getSignerInfos();
            Collection c = signers.getSigners();
            Iterator it = c.iterator();
            //the following array will contain the content of xml document
            //byte[] data = null;
            while (it.hasNext()) {
                SignerInformation signer = (SignerInformation) it.next();
                Collection certCollection = cs.getMatches(signer.getSID());
                Iterator certIt = certCollection.iterator();
                X509CertificateHolder cert = (X509CertificateHolder) certIt.next();

                CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
                InputStream in2 = new ByteArrayInputStream(cert.getEncoded());
                result = (X509Certificate) certFactory.generateCertificate(in2);

                if( null != result)
                    break;
                //CMSProcessable sc = signature.getSignedContent();
                //data = (byte[]) sc.getContent();
            }
        } catch (CertificateException | CMSException | IOException e) {
            log.error("",e);
        }
        return result;
2020/11/12 13:38 2020/11/12 13:38