manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1459940 - /manifoldcf/branches/CONNECTORS-664/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java
Date Fri, 22 Mar 2013 19:25:46 GMT
Author: kwright
Date: Fri Mar 22 19:25:46 2013
New Revision: 1459940

URL: http://svn.apache.org/r1459940
Log:
Use PEM encoding for cert, always

Modified:
    manifoldcf/branches/CONNECTORS-664/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java

Modified: manifoldcf/branches/CONNECTORS-664/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-664/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java?rev=1459940&r1=1459939&r2=1459940&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-664/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java
(original)
+++ manifoldcf/branches/CONNECTORS-664/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LLSERVER.java
Fri Mar 22 19:25:46 2013
@@ -131,10 +131,34 @@ public class LLSERVER
               java.security.cert.Certificate cert = keystore.getCertificate(alias);
               byte[] certData = cert.getEncoded();
               File fileName = new File(certFolder,ManifoldCF.safeFileName(alias) + ".cer");
-              FileOutputStream fos = new FileOutputStream(fileName);
+              OutputStream fos = new FileOutputStream(fileName);
               try
               {
-                fos.write(certData);
+                Writer osw = new OutputStreamWriter(fos,"utf-8");
+                try
+                {
+                  String certBase64 = new Base64().encodeByteArray(certData);
+                  osw.write("-----BEGIN CERTIFICATE-----\n");
+                  int index = 0;
+                  while (true)
+                  {
+                    if (certBase64.length() - index > 64)
+                    {
+                      osw.write(certBase64.substring(index,index+64) + "\n");
+                      index += 64;
+                    }
+                    else
+                    {
+                      osw.write(certBase64.substring(index) + "\n");
+                      break;
+                    }
+                  }
+                  osw.write("-----END CERTIFICATE-----\n");
+                }
+                finally
+                {
+                  osw.flush();
+                }
               }
               finally
               {



Mime
View raw message