Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x509: certificate is valid for pc01, not localhost #827

Open
marcoippolito opened this issue Jan 30, 2019 · 1 comment
Open

x509: certificate is valid for pc01, not localhost #827

marcoippolito opened this issue Jan 30, 2019 · 1 comment

Comments

@marcoippolito
Copy link

marcoippolito commented Jan 30, 2019

Hi,

trying to figure out how to use pq for the very first time, a strange error message appeared:

x509: certificate is valid for pc01, not localhost
exit status 1

postgres-11 is working in my Ubuntu 18.04.01 Server Edition:

postgres@pc01:~$ psql
psql (11.1 (Ubuntu 11.1-3.pgdg18.04+1))

postgres=# SELECT version();
                                                         version
--------------------------------------------------------------------------------------------------------- -
PostgreSQL 11.1 (Ubuntu 11.1-3.pgdg18.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu  
7.3.0-27ubuntu1~18.04) 7.3.0, 64-bit

postgres=# SELECT * FROM weather;
     city      | temp_lo | temp_hi | prcp |    date
---------------+---------+---------+------+------------
 San Francisco |      46 |      50 | 0.25 | 1994-11-27
 Hayward       |      37 |      54 |      | 1994-11-29
 San Francisco |      43 |      57 |    0 | 1994-11-29
 (3 rows)

This is the piece of code I'm trying to make it working:

package main

import (
    "log"
    "database/sql"
    _ "github.com/lib/pq"
)

var db *sql.DB

type Row struct {
        city string
        temp_lo int
        temp_hi int
        prcp float32  
        date string
}

func main() {
        connStr := "user=pqtest dbname=mydb sslmode=verify-full"
        db, err := sql.Open("postgres", connStr)
        if err != nil {
                log.Fatal(err)
        }
       defer rows.Close()
        for rows.Next() {

       }
}

And this is the go version installed:

go version go1.10.4 linux/amd64

What am I missing?
Looking forward to your kind help.
Marco

@rogerhub
Copy link

Have you tried deleting sslmode=verify-full? (Or add host=pc01, which I assume is your hostname)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants