EX-5 2 a2163739zex-5.htm EXHIBIT 5
QuickLinks -- Click here to rapidly navigate through this document


EXHIBIT 5
  
Opinion of Shumaker Williams, P.C.
of Camp Hill, Pennsylvania
Re: Legality of Securities


October 7, 2005

Board of Directors
Mid Penn Bancorp, Inc.
349 Union Street
Millersburg, Pennsylvania 17061

    RE:
    Mid Penn Bancorp, Inc.
    Registration Statement on Form S-3
    Our File No. 775-97

Ladies and Gentlemen:

        We have acted as Special Corporate Counsel to Mid Penn Bancorp, Inc. a Pennsylvania business corporation (the "Corporation") in connection with its registration statement on Form S-3 (the "Registration Statement") pertaining to the Corporation's Dividend Reinvestment and Stock Purchase (the "Plan") to be filed with the Securities and Exchange Commission relating to the registration of 300,000 shares of its common stock available for issuance pursuant to the Corporation's Plan.

        In connection with the foregoing, we have examined the following documents:

    The Corporation's Articles of Incorporation, as amended;

    The Corporation's Bylaws;

    Resolutions adopted by the Corporation's Board of Directors on September 28, 2005, relating to the Registration Statement, certified by the Corporate Secretary;

    The Plan; and

    The Registration Statement.

        In our examination, we have assumed the genuineness of all signatures, the authenticity of all documents submitted to us as originals and the conformity with the original documents of documents submitted to us as copies. As to any facts material to our opinion, we have, to the extent that relevant facts were not independently established by us, relied on certificates of public officials and certificates, oaths and declarations of officers or other representatives of the Corporation.

        On the basis of the foregoing and in reliance thereon, it is our opinion that the Corporation's common stock, par value $1.00 per share, issuable under the Plan, when issued in accordance with the provisions of the Plan and the Registration Statement, will be legally and validly issued, fully paid, and non-assessable.

        In giving the foregoing opinion, we have assumed that the Corporation will have, at the time of the issuance of common stock under the Plan, a sufficient number of authorized shares available for issue.

        We consent to the use of this opinion as an exhibit to the Corporation's Registration Statement and to the reference to our firm appearing in the prospectus filed as part of the Registration Statement, filed by the Corporation with the Securities and Exchange Commission, relating to the Plan, as well as to any amendments or supplements thereto. In giving this consent, we do not admit that we come within the category of persons whose consent is required under Sections 7 or 11 of the Securities Act of 1933, as amended, or the rules and regulations thereunder.

                        Very truly yours,
                           
                        /s/ Shumaker Williams, P.C.



                        SHUMAKER WILLIAMS, P.C




QuickLinks

EXHIBIT 5 Opinion of Shumaker Williams, P.C. of Camp Hill, Pennsylvania Re: Legality of Securities