--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENCE Sat Jun 27 21:55:53 2015 +0200
@@ -0,0 +1,16 @@
+This vim-plugin is intendet to fold Certs in PEM files
+Copyright (C) 2015 Heike Yvonne Pesch
+ heike.dasinci.pesch@googlemail.com
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README Sat Jun 27 21:55:53 2015 +0200
@@ -0,0 +1,103 @@
+ABOUT
+--------------------------------------------------------------------------------
+This Plugin is intended to fold every single Cert in a PEM Certificat.
+
+It will match on these filename extensions for X.509 certificates:
+
+ .pem – (Privacy-enhanced Electronic Mail) Base64 encoded DER certificate,
+ enclosed between "-----BEGIN CERTIFICATE-----" and
+ "-----END CERTIFICATE-----"
+ .p12 – PKCS#12, may contain certificate(s) (public) and private keys
+ (password protected)
+ .pfx – PFX, predecessor of PKCS#12 (usually contains data in PKCS#12
+ format, e.g., with PFX files generated in IIS)
+ .cer, .crt, .der – usually in binary DER form, but Base64-encoded
+ certificates are common too (see .pem above)
+ .p7b, .p7c – PKCS#7 SignedData structure without data, just certificate(s)
+ or CRL(s)
+ (origin: https://en.wikipedia.org/wiki/X.509)
+and also PEM Certificates with no file-ending.
+
+These days it only fold lines matching ^-----B, maybe when there is enough time,
+it'll also fold at these places. Intendet foldlevels [n]
+
+ Certificate [1]
+ Version [2]
+ Serial Number [2]
+ Algorithm ID [2]
+ Issuer [2]
+ Validity [2]
+ Not Before [3]
+ Not After [3]
+ Subject [2]
+ Subject Public Key Info [2]
+ Public Key Algorithm [2]
+ Subject Public Key [2]
+ Issuer Unique Identifier (optional) [2]
+ Subject Unique Identifier (optional) [2]
+ Extensions (optional) [2]
+ ...
+ Certificate Signature Algorithm [1||2]
+ Certificate Signature [1||2]
+
+
+
+INSTALLATION
+--------------------------------------------------------------------------------
+If you use pathogen Plugin for vim, put the entire folder in your ~/.vim/bundle.
+If you don't use pathogen Plugin, you have to do it - back to the roots -
+adjust your vim runtimepath (see :help 'runtimepath') and put the files in a
+location recodnized by your runtimepath. Or just install pathogen, it makes it
+much easier to update your plugins.
+
+Installing Pathogen Plugin is quiet easy, just enter:
+
+mkdir -p ~/.vim/autoload ~/.vim/bundle
+curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
+
+for more information visit:
+http://www.vim.org/scripts/script.php?script_id=2332
+
+RFC
+--------------------------------------------------------------------------------
+For more information about X-509 Certificates read the RFC:
+https://tools.ietf.org/html/rfc5280
+
+================================================================================
+================================================================================
+
+LICENCE
+--------------------------------------------------------------------------------
+This vim-plugin is intendet to fold Certs in PEM files
+Copyright (C) 2015 Heike Yvonne Pesch
+ heike.dasinci.pesch@googlemail.com
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+This vim-plugin is intendet to fold Certs in PEM files
+Copyright (C) 2015 Heike Yvonne Pesch
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/filetype.vim Sat Jun 27 21:55:53 2015 +0200
@@ -0,0 +1,7 @@
+if exists("did_load_filetypes")
+ finish
+endif
+
+au BufRead,BufNewFile *.cabundle\|cer\|crt\|der setfiletype PEM
+au BufRead,BufNewFile *.p12\|p7b\|p7c\|pem\|pfx setfiletype PEM
+au BufRead,BufNewFile * if getline(1) =~? '^-{5}b' || getline(1) =~? '^certificate:' | setfiletype PEM | endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ftplugin/PEM/folding.vim Sat Jun 27 21:55:53 2015 +0200
@@ -0,0 +1,102 @@
+" vim: foldmethod=marker
+set foldmethod=expr
+set foldexpr=GetPEMfold(v:lnum)
+set foldtext=SetFoldTextCN()
+
+function! GetPEMfold(lnum)
+"{{{1
+ if getline(a:lnum) =~? '\v^\s*$'
+ return '-1'
+ elseif getline(a:lnum) =~? '\v^certificate:'
+ return '>1'
+ elseif getline(a:lnum) =~? '\v^-{5}begin\scertificate-{5}'
+ return '>1'
+ endif
+
+ let this_indent = GetShiftLevel(a:lnum)
+ let next_indent = GetShiftLevel(GetNonBlankLines(a:lnum))
+ let begin_cert = GetShiftLevel(GetBeginCertificate(a:lnum))
+
+ if this_indent == begin_cert
+ return '1'
+ elseif this_indent == next_indent || this_indent > next_indent
+ return this_indent
+ elseif this_indent < next_indent
+ return '>' . next_indent
+ endif
+
+endfunction
+"}}}
+
+function! GetShiftLevel(lnum)
+"{{{1
+ "return indent(a:lnum) / &shiftwidth
+ return indent(a:lnum) / 4
+endfunction
+"}}}
+
+function! GetNonBlankLines(lnum)
+"{{{1
+ let numlines = line('$')
+ let current = a:lnum + 1
+
+ while current <= numlines
+ if getline(current) =~? '\v\S'
+ return current
+ endif
+
+ let current += 1
+
+ endwhile
+
+ return -2
+endfunction
+"}}}
+
+function! GetBeginCertificate(lnum)
+"{{{1
+ let numlines = line('$')
+ let current = a:lnum + 1
+
+ while current <= numlines
+ if getline(current) =~? '\v^-{5}begin\scertificate-{5}'
+ return current
+ endif
+
+ let current += 1
+ endwhile
+
+endfunction
+"}}}
+
+function! SetFoldTextCN()
+"{{{1
+
+ let line = getline(v:foldstart)
+ let lines_count = v:foldend - v:foldstart + 1
+ let lines_count_text = '| ' . printf("%10s", lines_count . ' lines') . ' |'
+ let foldchar = matchstr(&fillchars, 'fold:\zs.')
+ let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
+ let foldtextend = lines_count_text . repeat(foldchar, 8)
+
+ if match( line, 'Certificate:.*' ) == 0
+ let current = line + 1
+
+ while current <= lines_count
+ if ( getline(current) =~? 'CN=.*')
+ let inLine = getline(current)
+ let CName = substitute( inLine, '.*CN=\(.*$\)', "\\1", 'g')
+ endif
+ let current += 1
+ endwhile
+
+ let foldtextlength = strlen(substitute(foldtextstart . CName . foldtextend, '.', 'x', 'g')) + &foldcolumn
+ return foldtextstart . ' ' . CName . repeat(foldchar, winwidth(0)-foldtextlength-1) . foldtextend
+
+ else
+ let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
+ return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
+ endif
+
+endfunction
+"}}}